rgen 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/CHANGELOG +28 -0
  2. data/Rakefile +3 -4
  3. data/lib/ea_support/uml13_ea_metamodel.rb +3 -3
  4. data/lib/ea_support/uml13_ea_to_uml13.rb +33 -2
  5. data/lib/ea_support/uml13_to_uml13_ea.rb +7 -0
  6. data/lib/mmgen/mm_ext/ecore_mmgen_ext.rb +4 -4
  7. data/lib/mmgen/templates/metamodel_generator.tpl +143 -143
  8. data/lib/rgen/ecore/ecore.rb +11 -1
  9. data/lib/rgen/ecore/ecore_interface.rb +47 -0
  10. data/lib/rgen/ecore/ecore_to_ruby.rb +166 -0
  11. data/lib/rgen/ecore/{ecore_transformer.rb → ruby_to_ecore.rb} +11 -11
  12. data/lib/rgen/environment.rb +15 -2
  13. data/lib/rgen/fragment/dump_file_cache.rb +63 -0
  14. data/lib/rgen/fragment/fragmented_model.rb +139 -0
  15. data/lib/rgen/fragment/model_fragment.rb +268 -0
  16. data/lib/rgen/instantiator/abstract_xml_instantiator.rb +44 -72
  17. data/lib/rgen/instantiator/default_xml_instantiator.rb +2 -2
  18. data/lib/rgen/instantiator/ecore_xml_instantiator.rb +16 -1
  19. data/lib/rgen/instantiator/json_instantiator.rb +16 -2
  20. data/lib/rgen/instantiator/nodebased_xml_instantiator.rb +118 -138
  21. data/lib/rgen/instantiator/qualified_name_resolver.rb +5 -1
  22. data/lib/rgen/instantiator/reference_resolver.rb +126 -24
  23. data/lib/rgen/instantiator/xmi11_instantiator.rb +6 -2
  24. data/lib/rgen/metamodel_builder.rb +18 -6
  25. data/lib/rgen/metamodel_builder/builder_extensions.rb +431 -407
  26. data/lib/rgen/metamodel_builder/builder_runtime.rb +8 -8
  27. data/lib/rgen/metamodel_builder/constant_order_helper.rb +4 -4
  28. data/lib/rgen/metamodel_builder/data_types.rb +5 -1
  29. data/lib/rgen/metamodel_builder/intermediate/feature.rb +167 -0
  30. data/lib/rgen/metamodel_builder/module_extension.rb +2 -2
  31. data/lib/rgen/model_builder.rb +10 -5
  32. data/lib/rgen/model_builder/builder_context.rb +17 -1
  33. data/lib/rgen/serializer/opposite_reference_filter.rb +18 -0
  34. data/lib/rgen/serializer/qualified_name_provider.rb +45 -0
  35. data/lib/rgen/template_language/template_container.rb +3 -1
  36. data/lib/rgen/{auto_class_creator.rb → util/auto_class_creator.rb} +6 -1
  37. data/lib/rgen/util/cached_glob.rb +67 -0
  38. data/lib/rgen/util/file_cache_map.rb +104 -0
  39. data/lib/rgen/util/file_change_detector.rb +78 -0
  40. data/lib/rgen/{method_delegation.rb → util/method_delegation.rb} +18 -3
  41. data/lib/rgen/{model_comparator.rb → util/model_comparator.rb} +17 -5
  42. data/lib/rgen/{model_comparator_base.rb → util/model_comparator_base.rb} +6 -1
  43. data/lib/rgen/{model_dumper.rb → util/model_dumper.rb} +6 -1
  44. data/lib/rgen/{name_helper.rb → util/name_helper.rb} +6 -1
  45. data/lib/rgen/util/pattern_matcher.rb +329 -0
  46. data/lib/transformers/uml13_to_ecore.rb +103 -60
  47. data/test/ecore_self_test.rb +43 -42
  48. data/test/json_test.rb +15 -0
  49. data/test/metamodel_builder_test.rb +361 -206
  50. data/test/metamodel_from_ecore_test.rb +45 -0
  51. data/test/metamodel_order_test.rb +10 -4
  52. data/test/metamodel_roundtrip_test.rb +2 -2
  53. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +1 -1
  54. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +50 -50
  55. data/test/method_delegation_test.rb +9 -9
  56. data/test/model_builder/ecore_internal.rb +19 -9
  57. data/test/model_builder/serializer_test.rb +1 -1
  58. data/test/reference_resolver_test.rb +79 -12
  59. data/test/rgen_test.rb +2 -0
  60. data/test/template_language_test.rb +7 -0
  61. data/test/template_language_test/templates/callback_indent_test/a.tpl +12 -0
  62. data/test/template_language_test/templates/callback_indent_test/b.tpl +5 -0
  63. data/test/testmodel/ea_testmodel_regenerated.xml +588 -583
  64. data/test/transformer_test.rb +3 -3
  65. data/test/util/file_cache_map_test.rb +91 -0
  66. data/test/util/file_cache_map_test/testdir/fileA +1 -0
  67. data/test/util_test.rb +4 -0
  68. data/test/xml_instantiator_test.rb +139 -135
  69. metadata +49 -104
  70. data/lib/rgen/ecore/ecore_instantiator.rb +0 -31
  71. data/lib/rgen/metamodel_builder/metamodel_description.rb +0 -232
  72. data/redist/xmlscan/ChangeLog +0 -1301
  73. data/redist/xmlscan/README +0 -34
  74. data/redist/xmlscan/THANKS +0 -11
  75. data/redist/xmlscan/doc/changes.html +0 -74
  76. data/redist/xmlscan/doc/changes.rd +0 -80
  77. data/redist/xmlscan/doc/en/conformance.html +0 -136
  78. data/redist/xmlscan/doc/en/conformance.rd +0 -152
  79. data/redist/xmlscan/doc/en/manual.html +0 -356
  80. data/redist/xmlscan/doc/en/manual.rd +0 -402
  81. data/redist/xmlscan/doc/ja/conformance.ja.html +0 -118
  82. data/redist/xmlscan/doc/ja/conformance.ja.rd +0 -134
  83. data/redist/xmlscan/doc/ja/manual.ja.html +0 -325
  84. data/redist/xmlscan/doc/ja/manual.ja.rd +0 -370
  85. data/redist/xmlscan/doc/src/Makefile +0 -41
  86. data/redist/xmlscan/doc/src/conformance.rd.src +0 -256
  87. data/redist/xmlscan/doc/src/langsplit.rb +0 -110
  88. data/redist/xmlscan/doc/src/manual.rd.src +0 -614
  89. data/redist/xmlscan/install.rb +0 -41
  90. data/redist/xmlscan/lib/xmlscan/encoding.rb +0 -311
  91. data/redist/xmlscan/lib/xmlscan/htmlscan.rb +0 -289
  92. data/redist/xmlscan/lib/xmlscan/namespace.rb +0 -352
  93. data/redist/xmlscan/lib/xmlscan/parser.rb +0 -299
  94. data/redist/xmlscan/lib/xmlscan/scanner.rb +0 -1109
  95. data/redist/xmlscan/lib/xmlscan/version.rb +0 -22
  96. data/redist/xmlscan/lib/xmlscan/visitor.rb +0 -158
  97. data/redist/xmlscan/lib/xmlscan/xmlchar.rb +0 -441
  98. data/redist/xmlscan/memo/CONFORMANCE +0 -1249
  99. data/redist/xmlscan/memo/PRODUCTIONS +0 -195
  100. data/redist/xmlscan/memo/contentspec.ry +0 -335
  101. data/redist/xmlscan/samples/chibixml.rb +0 -105
  102. data/redist/xmlscan/samples/getxmlchar.rb +0 -122
  103. data/redist/xmlscan/samples/rexml.rb +0 -159
  104. data/redist/xmlscan/samples/xmlbench.rb +0 -88
  105. data/redist/xmlscan/samples/xmlbench/parser/chibixml.rb +0 -22
  106. data/redist/xmlscan/samples/xmlbench/parser/nqxml.rb +0 -29
  107. data/redist/xmlscan/samples/xmlbench/parser/rexml.rb +0 -62
  108. data/redist/xmlscan/samples/xmlbench/parser/xmlparser.rb +0 -22
  109. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-0.0.10.rb +0 -62
  110. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb +0 -22
  111. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb +0 -22
  112. data/redist/xmlscan/samples/xmlbench/parser/xmlscan.rb +0 -99
  113. data/redist/xmlscan/samples/xmlbench/xmlbench-lib.rb +0 -116
  114. data/redist/xmlscan/samples/xmlconftest.rb +0 -200
  115. data/redist/xmlscan/test.rb +0 -7
  116. data/redist/xmlscan/tests/deftestcase.rb +0 -73
  117. data/redist/xmlscan/tests/runtest.rb +0 -47
  118. data/redist/xmlscan/tests/testall.rb +0 -14
  119. data/redist/xmlscan/tests/testencoding.rb +0 -438
  120. data/redist/xmlscan/tests/testhtmlscan.rb +0 -752
  121. data/redist/xmlscan/tests/testnamespace.rb +0 -457
  122. data/redist/xmlscan/tests/testparser.rb +0 -591
  123. data/redist/xmlscan/tests/testscanner.rb +0 -1749
  124. data/redist/xmlscan/tests/testxmlchar.rb +0 -143
  125. data/redist/xmlscan/tests/visitor.rb +0 -34
@@ -1,752 +0,0 @@
1
- #
2
- # tests/testhtmlscan.rb
3
- #
4
- # Copyright (C) UENO Katsuhiro 2002
5
- #
6
- # $Id: testhtmlscan.rb,v 1.19 2003/02/28 12:31:07 katsu Exp $
7
- #
8
-
9
- require 'test/unit'
10
- require 'deftestcase'
11
- require 'xmlscan/htmlscan'
12
- require 'visitor'
13
-
14
-
15
- class TestHTMLScanner < Test::Unit::TestCase
16
-
17
- include DefTestCase
18
-
19
- Visitor = RecordingVisitor.new_class(XMLScan::Visitor)
20
-
21
-
22
- private
23
-
24
- def setup
25
- @v = Visitor.new
26
- @s = XMLScan::HTMLScanner.new(@v)
27
- end
28
-
29
- def parse(src)
30
- @s.parse src
31
- @v.result
32
- end
33
-
34
-
35
- public
36
-
37
- deftestcase 'html_comment', <<-'TESTCASEEND'
38
-
39
- '<!-- hogefuga -->'
40
- [ :on_comment, ' hogefuga ' ]
41
-
42
- '<!-- hoge<a>fuga -->'
43
- [ :on_comment, ' hoge<a>fuga ' ]
44
-
45
- '<!-- hoge<<<>>><<<a>>>fuga -->'
46
- [ :on_comment, ' hoge<<<>>><<<a>>>fuga ' ]
47
-
48
- '<!-- hoge-fuga -->'
49
- [ :on_comment, ' hoge-fuga ' ]
50
-
51
- '<!-- hogefuga'
52
- [ :parse_error, 'unterminated comment meets EOF' ]
53
- [ :on_comment, ' hogefuga' ]
54
-
55
- '<!-- hoge -- -- fuga -->'
56
- [ :on_comment, ' hoge -- -- fuga ' ]
57
-
58
- '<!-- hoge--fuga -->'
59
- [ :parse_error, "only whitespace can appear between two comments" ]
60
- [ :on_comment, ' hoge--fuga ' ]
61
-
62
- '<!-- hoge--fuga'
63
- [ :parse_error, "only whitespace can appear between two comments" ]
64
- [ :parse_error, 'unterminated comment meets EOF' ]
65
- [ :on_comment, ' hoge--fuga' ]
66
-
67
- # should be parsed as |<!--|- hogefuga |--|->|
68
- '<!--- hogefuga --->'
69
- [ :parse_error, "only whitespace can appear between two comments"]
70
- [ :parse_error, "`-->' is found but comment must not end here"]
71
- [ :on_comment, '- hogefuga -' ]
72
-
73
- '<!--- hogefuga --- >'
74
- [ :parse_error, "only whitespace can appear between two comments"]
75
- [ :parse_error, "`-->' is found but comment must not end here"]
76
- [ :on_comment, '- hogefuga -' ]
77
-
78
- # should be parsed as |<!--|--|--|-->|
79
- '<!-------->'
80
- [ :on_comment, '----' ]
81
-
82
- # should be parsed as |<!--|--|--|->|
83
- '<!------->'
84
- [ :parse_error, "`-->' is found but comment must not end here"]
85
- [ :on_comment, '---' ]
86
-
87
- # should be parsed as |<!--|--|--|>|
88
- '<!------>'
89
- [ :parse_error, "`-->' is found but comment must not end here"]
90
- [ :on_comment, '--' ]
91
-
92
- # should be parsed as |<!--|--|->|
93
- '<!----->'
94
- [ :parse_error, "only whitespace can appear between two comments"]
95
- [ :parse_error, "`-->' is found but comment must not end here"]
96
- [ :on_comment, '-' ]
97
-
98
- '<!---->'
99
- [ :on_comment, '' ]
100
-
101
- '<!--->'
102
- [ :parse_error, 'unterminated comment meets EOF' ]
103
- [ :on_comment, '->' ]
104
-
105
- '<!-->'
106
- [ :parse_error, 'unterminated comment meets EOF' ]
107
- [ :on_comment, '>' ]
108
-
109
- '<!--hoge-->fuga'
110
- [ :on_comment, 'hoge' ]
111
- [ :on_chardata, 'fuga' ]
112
-
113
- '<!--hoge-- >fuga'
114
- [ :on_comment, 'hoge' ]
115
- [ :on_chardata, 'fuga' ]
116
-
117
- '<!--hoge-->>'
118
- [ :on_comment, 'hoge' ]
119
- [ :on_chardata, '>' ]
120
-
121
- '<!--hoge--fuga-->hoge'
122
- [ :parse_error, "only whitespace can appear between two comments"]
123
- [ :on_comment, 'hoge--fuga' ]
124
- [ :on_chardata, 'hoge' ]
125
-
126
- TESTCASEEND
127
-
128
-
129
-
130
- deftestcase 'pi', <<-'TESTCASEEND'
131
-
132
- '<?hoge fuga?>'
133
- [ :on_pi, '', 'hoge fuga?' ]
134
-
135
- '<?xml version="1.0"?>'
136
- [ :on_pi, '', 'xml version="1.0"?' ]
137
-
138
- '<?hoge fuga>'
139
- [ :on_pi, '', 'hoge fuga' ]
140
-
141
- '<?hoge >'
142
- [ :on_pi, '', 'hoge ' ]
143
-
144
- '<?hoge>'
145
- [ :on_pi, '', 'hoge' ]
146
-
147
- '<?hoge <<a<<<a<<< >'
148
- [ :on_pi, '', 'hoge <<a<<<a<<< ' ]
149
-
150
- '<?hoge<>'
151
- [ :on_pi, '', 'hoge<' ]
152
-
153
- '<? >'
154
- [ :on_pi, '', ' ' ]
155
-
156
- '<?>'
157
- [ :on_pi, '', '' ]
158
-
159
- '<?'
160
- [ :parse_error, "unterminated PI meets EOF" ]
161
- [ :on_pi, '', '' ]
162
-
163
- '<?hoge>fuga'
164
- [ :on_pi, '', 'hoge' ]
165
- [ :on_chardata, 'fuga' ]
166
-
167
- '<?hoge>>'
168
- [ :on_pi, '', 'hoge' ]
169
- [ :on_chardata, '>' ]
170
-
171
- TESTCASEEND
172
-
173
-
174
-
175
- deftestcase 'stag', <<-'TESTCASEEND'
176
-
177
- '<hoge>'
178
- [ :on_stag, 'hoge' ]
179
- [ :on_stag_end, 'hoge' ]
180
-
181
- '<hoge >'
182
- [ :on_stag, 'hoge' ]
183
- [ :on_stag_end, 'hoge' ]
184
-
185
- '<hoge'
186
- [ :on_stag, 'hoge' ]
187
- [ :parse_error, "unclosed start tag `hoge' meets EOF" ]
188
- [ :on_stag_end, 'hoge' ]
189
-
190
- '<hoge<fuga>'
191
- [ :on_stag, 'hoge' ]
192
- [ :parse_error, "unclosed start tag `hoge' meets another tag" ]
193
- [ :on_stag_end, 'hoge' ]
194
- [ :on_stag, 'fuga' ]
195
- [ :on_stag_end, 'fuga' ]
196
-
197
- '<hoge <fuga>'
198
- [ :on_stag, 'hoge' ]
199
- [ :parse_error, "unclosed start tag `hoge' meets another tag" ]
200
- [ :on_stag_end, 'hoge' ]
201
- [ :on_stag, 'fuga' ]
202
- [ :on_stag_end, 'fuga' ]
203
-
204
- '< hoge>'
205
- [ :parse_error, "parse error at `<'" ]
206
- [ :on_chardata, '< hoge>' ]
207
-
208
- '<hoge/>'
209
- [ :on_stag, 'hoge' ]
210
- [ :parse_error, "parse error at `/'" ]
211
- [ :on_stag_end, 'hoge' ]
212
-
213
- '<hoge= >'
214
- [ :on_stag, 'hoge' ]
215
- [ :parse_error, "parse error at `='" ]
216
- [ :on_stag_end, 'hoge' ]
217
-
218
- '<=hoge >'
219
- [ :parse_error, "parse error at `<'" ]
220
- [ :on_chardata, '<=hoge >' ]
221
-
222
- '< =hoge >'
223
- [ :parse_error, "parse error at `<'" ]
224
- [ :on_chardata, '< =hoge >' ]
225
-
226
- '<hoge>fuga'
227
- [ :on_stag, 'hoge' ]
228
- [ :on_stag_end, 'hoge' ]
229
- [ :on_chardata, 'fuga' ]
230
-
231
- '<hoge>>'
232
- [ :on_stag, 'hoge' ]
233
- [ :on_stag_end, 'hoge' ]
234
- [ :on_chardata, '>' ]
235
-
236
- '< hoge>fuga'
237
- [ :parse_error, "parse error at `<'" ]
238
- [ :on_chardata, '< hoge>' ]
239
- [ :on_chardata, 'fuga' ]
240
-
241
- '< hoge>>'
242
- [ :parse_error, "parse error at `<'" ]
243
- [ :on_chardata, '< hoge>' ]
244
- [ :on_chardata, '>' ]
245
-
246
- '<hoge/>'
247
- [ :on_stag, 'hoge' ]
248
- [ :parse_error, "parse error at `/'" ]
249
- [ :on_stag_end, 'hoge' ]
250
-
251
- '<hoge/>fuga'
252
- [ :on_stag, 'hoge' ]
253
- [ :parse_error, "parse error at `/'" ]
254
- [ :on_stag_end, 'hoge' ]
255
- [ :on_chardata, 'fuga' ]
256
-
257
- '<hoge/>>'
258
- [ :on_stag, 'hoge' ]
259
- [ :parse_error, "parse error at `/'" ]
260
- [ :on_stag_end, 'hoge' ]
261
- [ :on_chardata, '>' ]
262
-
263
- TESTCASEEND
264
-
265
-
266
-
267
- deftestcase 'attribute', <<-'TESTCASEEND'
268
-
269
- '<hoge foo="bar">'
270
- [ :on_stag, 'hoge' ]
271
- [ :on_attribute, 'foo' ]
272
- [ :on_attr_value, 'bar' ]
273
- [ :on_attribute_end, 'foo' ]
274
- [ :on_stag_end, 'hoge' ]
275
-
276
- '<hoge foo="">'
277
- [ :on_stag, 'hoge' ]
278
- [ :on_attribute, 'foo' ]
279
- [ :on_attribute_end, 'foo' ]
280
- [ :on_stag_end, 'hoge' ]
281
-
282
- "<hoge foo = ' bar ' HOGE = 'FUGA' >"
283
- [ :on_stag, 'hoge' ]
284
- [ :on_attribute, 'foo' ]
285
- [ :on_attr_value, ' bar ' ]
286
- [ :on_attribute_end, 'foo' ]
287
- [ :on_attribute, 'HOGE' ]
288
- [ :on_attr_value, 'FUGA' ]
289
- [ :on_attribute_end, 'HOGE' ]
290
- [ :on_stag_end, 'hoge' ]
291
-
292
- '<hoge foo="bar"/>'
293
- [ :on_stag, 'hoge' ]
294
- [ :on_attribute, 'foo' ]
295
- [ :on_attr_value, 'bar' ]
296
- [ :on_attribute_end, 'foo' ]
297
- [ :parse_error, "parse error at `/'" ]
298
- [ :on_stag_end, 'hoge' ]
299
-
300
- '<hoge foo=bar/>'
301
- [ :on_stag, 'hoge' ]
302
- [ :on_attribute, 'foo' ]
303
- [ :on_attr_value, 'bar/' ]
304
- [ :on_attribute_end, 'foo' ]
305
- [ :on_stag_end, 'hoge' ]
306
-
307
- '<hoge foo="b>a>b>c>ar">'
308
- [ :on_stag, 'hoge' ]
309
- [ :on_attribute, 'foo' ]
310
- [ :on_attr_value, 'b' ]
311
- [ :on_attr_value, '>' ]
312
- [ :on_attr_value, 'a' ]
313
- [ :on_attr_value, '>' ]
314
- [ :on_attr_value, 'b' ]
315
- [ :on_attr_value, '>' ]
316
- [ :on_attr_value, 'c' ]
317
- [ :on_attr_value, '>' ]
318
- [ :on_attr_value, 'ar' ]
319
- [ :on_attribute_end, 'foo' ]
320
- [ :on_stag_end, 'hoge' ]
321
-
322
- '<hoge foo="b>>a>>b>>c>>ar" HOGE="FUGA">'
323
- [ :on_stag, 'hoge' ]
324
- [ :on_attribute, 'foo' ]
325
- [ :on_attr_value, 'b' ]
326
- [ :on_attr_value, '>' ]
327
- [ :on_attr_value, '>' ]
328
- [ :on_attr_value, 'a' ]
329
- [ :on_attr_value, '>' ]
330
- [ :on_attr_value, '>' ]
331
- [ :on_attr_value, 'b' ]
332
- [ :on_attr_value, '>' ]
333
- [ :on_attr_value, '>' ]
334
- [ :on_attr_value, 'c' ]
335
- [ :on_attr_value, '>' ]
336
- [ :on_attr_value, '>' ]
337
- [ :on_attr_value, 'ar' ]
338
- [ :on_attribute_end, 'foo' ]
339
- [ :on_attribute, 'HOGE' ]
340
- [ :on_attr_value, 'FUGA' ]
341
- [ :on_attribute_end, 'HOGE' ]
342
- [ :on_stag_end, 'hoge' ]
343
-
344
- '<hoge foo="b<a>b<c>ar">'
345
- [ :on_stag, 'hoge' ]
346
- [ :on_attribute, 'foo' ]
347
- [ :on_attr_value, 'b' ]
348
- [ :on_attr_value, '<a' ]
349
- [ :on_attr_value, '>' ]
350
- [ :on_attr_value, 'b' ]
351
- [ :on_attr_value, '<c' ]
352
- [ :on_attr_value, '>' ]
353
- [ :on_attr_value, 'ar' ]
354
- [ :on_attribute_end, 'foo' ]
355
- [ :on_stag_end, 'hoge' ]
356
-
357
- '<hoge foo=bar>'
358
- [ :on_stag, 'hoge' ]
359
- [ :on_attribute, 'foo' ]
360
- [ :on_attr_value, 'bar' ]
361
- [ :on_attribute_end, 'foo' ]
362
- [ :on_stag_end, 'hoge' ]
363
-
364
- '<hoge foo = bar >'
365
- [ :on_stag, 'hoge' ]
366
- [ :on_attribute, 'foo' ]
367
- [ :on_attr_value, 'bar' ]
368
- [ :on_attribute_end, 'foo' ]
369
- [ :on_stag_end, 'hoge' ]
370
-
371
- '<hoge foo = bar&fuga;bar >'
372
- [ :on_stag, 'hoge' ]
373
- [ :on_attribute, 'foo' ]
374
- [ :on_attr_value, 'bar&fuga;bar' ]
375
- [ :on_attribute_end, 'foo' ]
376
- [ :on_stag_end, 'hoge' ]
377
-
378
- '<hoge foo = bar/baz%fuga >'
379
- [ :on_stag, 'hoge' ]
380
- [ :on_attribute, 'foo' ]
381
- [ :on_attr_value, 'bar/baz%fuga' ]
382
- [ :on_attribute_end, 'foo' ]
383
- [ :on_stag_end, 'hoge' ]
384
-
385
- '<hoge foo/bar = bar/baz%fuga >'
386
- [ :on_stag, 'hoge' ]
387
- [ :on_attribute, nil ]
388
- [ :on_attr_value, 'foo' ]
389
- [ :on_attribute_end, nil ]
390
- [ :parse_error, "parse error at `/'" ]
391
- [ :on_attribute, 'bar' ]
392
- [ :on_attr_value, 'bar/baz%fuga' ]
393
- [ :on_attribute_end, 'bar' ]
394
- [ :on_stag_end, 'hoge' ]
395
-
396
-
397
- '<hoge foo = bar hoge = fuga >'
398
- [ :on_stag, 'hoge' ]
399
- [ :on_attribute, 'foo' ]
400
- [ :on_attr_value, 'bar' ]
401
- [ :on_attribute_end, 'foo' ]
402
- [ :on_attribute, 'hoge' ]
403
- [ :on_attr_value, 'fuga' ]
404
- [ :on_attribute_end, 'hoge' ]
405
- [ :on_stag_end, 'hoge' ]
406
-
407
- '<hoge foo>'
408
- [ :on_stag, 'hoge' ]
409
- [ :on_attribute, nil ]
410
- [ :on_attr_value, 'foo' ]
411
- [ :on_attribute_end, nil ]
412
- [ :on_stag_end, 'hoge' ]
413
-
414
- '<hoge foo bar >'
415
- [ :on_stag, 'hoge' ]
416
- [ :on_attribute, nil ]
417
- [ :on_attr_value, 'foo' ]
418
- [ :on_attribute_end, nil ]
419
- [ :on_attribute, nil ]
420
- [ :on_attr_value, 'bar' ]
421
- [ :on_attribute_end, nil ]
422
- [ :on_stag_end, 'hoge' ]
423
-
424
- '<hoge foo&hoge;bar>'
425
- [ :on_stag, 'hoge' ]
426
- [ :on_attribute, nil ]
427
- [ :on_attr_value, 'foo&hoge;bar' ]
428
- [ :on_attribute_end, nil ]
429
- [ :on_stag_end, 'hoge' ]
430
-
431
- '<hoge foo = bar hoge >'
432
- [ :on_stag, 'hoge' ]
433
- [ :on_attribute, 'foo' ]
434
- [ :on_attr_value, 'bar' ]
435
- [ :on_attribute_end, 'foo' ]
436
- [ :on_attribute, nil ]
437
- [ :on_attr_value, 'hoge' ]
438
- [ :on_attribute_end, nil ]
439
- [ :on_stag_end, 'hoge' ]
440
-
441
- '<hoge foo = bar<fuga >'
442
- [ :on_stag, 'hoge' ]
443
- [ :on_attribute, 'foo' ]
444
- [ :on_attr_value, 'bar' ]
445
- [ :on_attribute_end, 'foo' ]
446
- [ :parse_error, "unclosed start tag `hoge' meets another tag" ]
447
- [ :on_stag_end, 'hoge' ]
448
- [ :on_stag, 'fuga' ]
449
- [ :on_stag_end, 'fuga' ]
450
-
451
- '<hoge foo="bar"HOGE ="FUGA">'
452
- [ :on_stag, 'hoge' ]
453
- [ :on_attribute, 'foo' ]
454
- [ :on_attr_value, 'bar' ]
455
- [ :on_attribute_end, 'foo' ]
456
- [ :on_attribute, 'HOGE' ]
457
- [ :on_attr_value, 'FUGA' ]
458
- [ :on_attribute_end, 'HOGE' ]
459
- [ :on_stag_end, 'hoge' ]
460
-
461
- '<hoge foo=bar=fuga >'
462
- [ :on_stag, 'hoge' ]
463
- [ :on_attribute, 'foo' ]
464
- [ :on_attr_value, 'bar' ]
465
- [ :on_attribute_end, 'foo' ]
466
- [ :parse_error, "parse error at `='" ]
467
- [ :on_attribute, nil ]
468
- [ :on_attr_value, 'fuga' ]
469
- [ :on_attribute_end, nil ]
470
- [ :on_stag_end, 'hoge' ]
471
-
472
- '<hoge foo="bar" <fuga>'
473
- [ :on_stag, 'hoge' ]
474
- [ :on_attribute, 'foo' ]
475
- [ :on_attr_value, 'bar' ]
476
- [ :on_attribute_end, 'foo' ]
477
- [ :parse_error, "unclosed start tag `hoge' meets another tag" ]
478
- [ :on_stag_end, 'hoge' ]
479
- [ :on_stag, 'fuga' ]
480
- [ :on_stag_end, 'fuga' ]
481
-
482
- '<hoge foo="bar>'
483
- [ :on_stag, 'hoge' ]
484
- [ :on_attribute, 'foo' ]
485
- [ :on_attr_value, 'bar' ]
486
- [ :on_attr_value, '>' ]
487
- [ :parse_error, "unterminated attribute `foo' meets EOF" ]
488
- [ :on_attribute_end, 'foo' ]
489
- [ :parse_error, "unclosed start tag `hoge' meets EOF" ]
490
- [ :on_stag_end, 'hoge' ]
491
-
492
- '<hoge foo= >'
493
- [ :on_stag, 'hoge' ]
494
- [ :on_attribute, nil ]
495
- [ :on_attr_value, 'foo' ]
496
- [ :on_attribute_end, nil ]
497
- [ :parse_error, "parse error at `='" ]
498
- [ :on_stag_end, 'hoge' ]
499
-
500
- '<hoge ="fuga" >'
501
- [ :on_stag, 'hoge' ]
502
- [ :parse_error, "parse error at `='" ]
503
- [ :parse_error, "parse error at `\"'" ]
504
- [ :on_attribute, nil ]
505
- [ :on_attr_value, 'fuga' ]
506
- [ :on_attribute_end, nil ]
507
- [ :parse_error, "parse error at `\"'" ]
508
- [ :on_stag_end, 'hoge' ]
509
-
510
- '<hoge "fuga" >'
511
- [ :on_stag, 'hoge' ]
512
- [ :parse_error, "parse error at `\"'" ]
513
- [ :on_attribute, nil ]
514
- [ :on_attr_value, 'fuga' ]
515
- [ :on_attribute_end, nil ]
516
- [ :parse_error, "parse error at `\"'" ]
517
- [ :on_stag_end, 'hoge' ]
518
-
519
- '<hoge"fuga" >'
520
- [ :on_stag, 'hoge' ]
521
- [ :parse_error, "parse error at `\"'" ]
522
- [ :on_attribute, nil ]
523
- [ :on_attr_value, 'fuga' ]
524
- [ :on_attribute_end, nil ]
525
- [ :parse_error, "parse error at `\"'" ]
526
- [ :on_stag_end, 'hoge' ]
527
-
528
- '<hoge = fuga >'
529
- [ :on_stag, 'hoge' ]
530
- [ :parse_error, "parse error at `='" ]
531
- [ :on_attribute, nil ]
532
- [ :on_attr_value, 'fuga' ]
533
- [ :on_attribute_end, nil ]
534
- [ :on_stag_end, 'hoge' ]
535
-
536
- TESTCASEEND
537
-
538
-
539
-
540
- deftestcase 'bang_tag', <<-'TESTCASEEND'
541
-
542
- '<!hoge>'
543
- [ :parse_error, "parse error at `<!'" ]
544
-
545
- '<!hoge fuga>'
546
- [ :parse_error, "parse error at `<!'" ]
547
-
548
- '<!hoge'
549
- [ :parse_error, "parse error at `<!'" ]
550
-
551
- '<!>'
552
- [ :on_comment, '' ]
553
-
554
- '<!'
555
- [ :parse_error, "parse error at `<!'" ]
556
-
557
- '<!hoge>fuga'
558
- [ :parse_error, "parse error at `<!'" ]
559
- [ :on_chardata, 'fuga' ]
560
-
561
- '<!hoge>>'
562
- [ :parse_error, "parse error at `<!'" ]
563
- [ :on_chardata, '>' ]
564
-
565
- TESTCASEEND
566
-
567
-
568
-
569
- deftestcase 'internal_dtd', <<-'TESTCASEEND'
570
-
571
- '<!DOCTYPE hoge[ <!ENTITY fuga "hoge"> ]>'
572
- [ :on_doctype, 'hoge', nil, nil ]
573
- [ :parse_error, "DTD subset is found but it is not permitted in HTML" ]
574
-
575
- TESTCASEEND
576
-
577
-
578
-
579
- deftestcase 'doctype', <<-'TESTCASEEND'
580
-
581
- '<!DOCTYPE hoge public "fuga">'
582
- [ :on_doctype, 'hoge', 'fuga', nil ]
583
-
584
- '<!DOCTYPE hoge system "fuga">'
585
- [ :on_doctype, 'hoge', nil, 'fuga' ]
586
-
587
- '<!DOCTYPE hoge PuBliC "fuga">'
588
- [ :on_doctype, 'hoge', 'fuga', nil ]
589
-
590
- '<!DOCTYPE hoge sYsTEm "fuga">'
591
- [ :on_doctype, 'hoge', nil, 'fuga' ]
592
-
593
- TESTCASEEND
594
-
595
-
596
-
597
- deftestcase 'prolog', <<-'TESTCASEEND'
598
-
599
- '<!DOCTYPE hoge><hoge>'
600
- [ :on_doctype, 'hoge', nil, nil ]
601
- [ :on_stag, 'hoge' ]
602
- [ :on_stag_end, 'hoge' ]
603
-
604
- '<!doctype hoge><hoge>'
605
- [ :on_doctype, 'hoge', nil, nil ]
606
- [ :on_stag, 'hoge' ]
607
- [ :on_stag_end, 'hoge' ]
608
-
609
- '<!dOcTyPe hoge><hoge>'
610
- [ :on_doctype, 'hoge', nil, nil ]
611
- [ :on_stag, 'hoge' ]
612
- [ :on_stag_end, 'hoge' ]
613
-
614
- '<hoge><!DOCTYPE hoge>'
615
- [ :on_stag, 'hoge' ]
616
- [ :on_stag_end, 'hoge' ]
617
- [ :parse_error, "parse error at `<!'" ]
618
-
619
- ' <!DOCTYPE hoge> <hoge>'
620
- [ :on_prolog_space, ' ' ]
621
- [ :on_doctype, 'hoge', nil, nil ]
622
- [ :on_prolog_space, ' ' ]
623
- [ :on_stag, 'hoge' ]
624
- [ :on_stag_end, 'hoge' ]
625
-
626
- '<!--hoge--><!DOCTYPE hoge><?fuga?><hoge>'
627
- [ :on_comment, 'hoge' ]
628
- [ :on_doctype, 'hoge', nil, nil ]
629
- [ :on_pi, '', 'fuga?' ]
630
- [ :on_stag, 'hoge' ]
631
- [ :on_stag_end, 'hoge' ]
632
-
633
- '<!--hoge--><!DOCTYPE hoge><!--fuga--><hoge>'
634
- [ :on_comment, 'hoge' ]
635
- [ :on_doctype, 'hoge', nil, nil ]
636
- [ :on_comment, 'fuga' ]
637
- [ :on_stag, 'hoge' ]
638
- [ :on_stag_end, 'hoge' ]
639
-
640
- '<!--hoge--> <hoge>'
641
- [ :on_comment, 'hoge' ]
642
- [ :on_prolog_space, ' ' ]
643
- [ :on_stag, 'hoge' ]
644
- [ :on_stag_end, 'hoge' ]
645
-
646
- '<?hoge?> <hoge>'
647
- [ :on_pi, '', 'hoge?' ]
648
- [ :on_prolog_space, ' ' ]
649
- [ :on_stag, 'hoge' ]
650
- [ :on_stag_end, 'hoge' ]
651
-
652
- 'hoge<!DOCTYPE hoge>'
653
- [ :on_chardata, 'hoge' ]
654
- [ :parse_error, "parse error at `<!'" ]
655
-
656
- '>hoge<!DOCTYPE hoge>'
657
- [ :on_chardata, '>hoge' ]
658
- [ :parse_error, "parse error at `<!'" ]
659
-
660
- '<?hoge?> fuga <!DOCTYPE hoge>'
661
- [ :on_pi, '', 'hoge?' ]
662
- [ :on_chardata, ' fuga ' ]
663
- [ :parse_error, "parse error at `<!'" ]
664
-
665
- '<!DOCTYPE hoge><!DOCTYPE fuga><hoge>'
666
- [ :on_doctype, 'hoge', nil, nil ]
667
- [ :parse_error, "another document type declaration is found" ]
668
- [ :on_doctype, 'fuga', nil, nil ]
669
- [ :on_stag, 'hoge' ]
670
- [ :on_stag_end, 'hoge' ]
671
-
672
- TESTCASEEND
673
-
674
- end
675
-
676
-
677
- class TestHTMLScannerCDATA < Test::Unit::TestCase
678
-
679
- include DefTestCase
680
-
681
- class CDATAContentTestVisitor < TestHTMLScanner::Visitor
682
- def make_scanner
683
- @scanner = XMLScan::HTMLScanner.new(self)
684
- end
685
- def on_stag_end(name)
686
- super
687
- s = @scanner.get_cdata_content
688
- @result.push [ :cdata_content, s ]
689
- end
690
- end
691
-
692
-
693
- private
694
-
695
- def setup
696
- @v = CDATAContentTestVisitor.new
697
- @s = @v.make_scanner
698
- end
699
-
700
- def parse(src)
701
- @s.parse src
702
- @v.result
703
- end
704
-
705
-
706
- public
707
-
708
- deftestcase 'cdata_content', <<-'TESTCASEEND'
709
-
710
- '<hoge>fuga</hoge>'
711
- [ :on_stag, 'hoge' ]
712
- [ :on_stag_end, 'hoge' ]
713
- [ :cdata_content, 'fuga' ]
714
- [ :on_etag, 'hoge' ]
715
-
716
- '<hoge>fuga<foo><bar>fuga</hoge>'
717
- [ :on_stag, 'hoge' ]
718
- [ :on_stag_end, 'hoge' ]
719
- [ :cdata_content, 'fuga<foo><bar>fuga' ]
720
- [ :on_etag, 'hoge' ]
721
-
722
- '<hoge>><><><<><a><>><></hoge>'
723
- [ :on_stag, 'hoge' ]
724
- [ :on_stag_end, 'hoge' ]
725
- [ :cdata_content, '><><><<><a><>><>' ]
726
- [ :on_etag, 'hoge' ]
727
-
728
- '<hoge>fuga</'
729
- [ :on_stag, 'hoge' ]
730
- [ :on_stag_end, 'hoge' ]
731
- [ :cdata_content, 'fuga' ]
732
- [ :parse_error, "parse error at `</'" ]
733
- [ :on_chardata, '</' ]
734
-
735
- '<hoge>fuga<'
736
- [ :on_stag, 'hoge' ]
737
- [ :on_stag_end, 'hoge' ]
738
- [ :cdata_content, 'fuga<' ]
739
-
740
- '<hoge>fuga>'
741
- [ :on_stag, 'hoge' ]
742
- [ :on_stag_end, 'hoge' ]
743
- [ :cdata_content, 'fuga>' ]
744
-
745
- TESTCASEEND
746
-
747
- end
748
-
749
-
750
-
751
-
752
- load "#{File.dirname($0)}/runtest.rb" if __FILE__ == $0