1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
|
# coding: US-ASCII
require 'rubygems'
require 'minitest/autorun'
require File.expand_path '../xref_test_case', __FILE__
require 'rdoc/code_object'
class TestRDocCodeObject < XrefTestCase
def setup
super
@co = RDoc::CodeObject.new
end
def test_initialize
assert @co.document_self, 'document_self'
assert @co.document_children, 'document_children'
refute @co.force_documentation, 'force_documentation'
refute @co.done_documenting, 'done_documenting'
refute @co.received_nodoc, 'received_nodoc'
assert_equal '', @co.comment, 'comment is empty'
end
def test_comment_equals
@co.comment = ''
assert_equal '', @co.comment
@co.comment = 'I am a comment'
assert_equal 'I am a comment', @co.comment
end
def test_comment_equals_document
doc = RDoc::Markup::Document.new
@co.comment = doc
@co.comment = ''
assert_equal doc, @co.comment
end
def test_comment_equals_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
input = 'text'
input.force_encoding Encoding::UTF_8
@co.comment = input
assert_equal 'text', @co.comment
assert_equal Encoding::UTF_8, @co.comment.encoding
end
def test_comment_equals_encoding_blank
skip "Encoding not implemented" unless Object.const_defined? :Encoding
refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
input = ''
input.force_encoding Encoding::UTF_8
@co.comment = input
assert_equal '', @co.comment
assert_equal Encoding::UTF_8, @co.comment.encoding
end
def test_display_eh_document_self
assert @co.display?
@co.document_self = false
refute @co.display?
end
def test_display_eh_ignore
assert @co.display?
@co.ignore
refute @co.display?
@co.stop_doc
refute @co.display?
@co.done_documenting = false
refute @co.display?
end
def test_document_children_equals
@co.document_children = false
refute @co.document_children
# TODO this is not true anymore:
# test all the nodoc stuff etc...
#@c2.document_children = false
#assert_empty @c2.classes
end
def test_document_self_equals
@co.document_self = false
refute @co.document_self
# TODO this is not true anymore:
# test all the nodoc stuff etc...
#@c1.document_self = false
#assert_empty @c1.method_list
end
def test_documented_eh
refute @co.documented?
@co.comment = 'hi'
assert @co.documented?
@co.comment.replace ''
refute @co.documented?
@co.document_self = nil # notify :nodoc:
assert @co.documented?
end
def test_done_documenting
# once done_documenting is set, other properties refuse to go to "true"
@co.done_documenting = true
@co.document_self = true
refute @co.document_self
@co.document_children = true
refute @co.document_children
@co.force_documentation = true
refute @co.force_documentation
@co.start_doc
refute @co.document_self
refute @co.document_children
# turning done_documenting on
# resets others to true
@co.done_documenting = false
assert @co.document_self
assert @co.document_children
end
def test_each_parent
parents = []
@parent_m.each_parent do |code_object|
parents << code_object
end
assert_equal [@parent, @xref_data], parents
end
def test_file_name
assert_equal nil, @co.file_name
@co.record_location RDoc::TopLevel.new 'lib/file.rb'
assert_equal 'lib/file.rb', @co.file_name
end
def test_full_name_equals
@co.full_name = 'hi'
assert_equal 'hi', @co.instance_variable_get(:@full_name)
@co.full_name = nil
assert_nil @co.instance_variable_get(:@full_name)
end
def test_ignore
@co.ignore
refute @co.document_self
refute @co.document_children
assert @co.ignored?
end
def test_ignore_eh
refute @co.ignored?
@co.ignore
assert @co.ignored?
end
def test_line
@c1_m.line = 5
assert_equal 5, @c1_m.line
end
def test_metadata
assert_empty @co.metadata
@co.metadata['markup'] = 'not_rdoc'
expected = { 'markup' => 'not_rdoc' }
assert_equal expected, @co.metadata
assert_equal 'not_rdoc', @co.metadata['markup']
end
def test_offset
@c1_m.offset = 5
assert_equal 5, @c1_m.offset
end
def test_parent_file_name
assert_equal '(unknown)', @co.parent_file_name
assert_equal 'xref_data.rb', @c1.parent_file_name
end
def test_parent_name
assert_equal '(unknown)', @co.parent_name
assert_equal 'xref_data.rb', @c1.parent_name
assert_equal 'C2', @c2_c3.parent_name
end
def test_received_ndoc
@co.document_self = false
refute @co.received_nodoc
@co.document_self = nil
assert @co.received_nodoc
@co.document_self = true
end
def test_record_location
@co.record_location @xref_data
assert_equal 'xref_data.rb', @co.file.relative_name
end
def test_record_location_ignored
@co.ignore
@co.record_location @xref_data
refute @co.ignored?
end
def test_start_doc
@co.document_self = false
@co.document_children = false
@co.start_doc
assert @co.document_self
assert @co.document_children
end
def test_start_doc_ignored
@co.ignore
@co.start_doc
assert @co.document_self
assert @co.document_children
refute @co.ignored?
end
def test_stop_doc
@co.document_self = true
@co.document_children = true
@co.stop_doc
refute @co.document_self
refute @co.document_children
end
end
|