kwalify 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/CHANGES.txt +232 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +16 -19
  4. data/bin/kwalify +3 -3
  5. data/contrib/inline-require +6 -4
  6. data/contrib/kwalify +3719 -2427
  7. data/doc-api/classes/CommandOptionError.html +17 -17
  8. data/doc-api/classes/CommandOptionParser.html +63 -63
  9. data/doc-api/classes/Kwalify.html +29 -7
  10. data/doc-api/classes/Kwalify/AssertionError.html +9 -9
  11. data/doc-api/classes/Kwalify/BaseError.html +72 -71
  12. data/doc-api/classes/Kwalify/BaseParser.html +461 -0
  13. data/doc-api/classes/Kwalify/CommandOptionError.html +11 -11
  14. data/doc-api/classes/Kwalify/ErrorHelper.html +51 -46
  15. data/doc-api/classes/Kwalify/HashInterface.html +13 -135
  16. data/doc-api/classes/Kwalify/Json.html +105 -0
  17. data/doc-api/classes/Kwalify/Main.html +129 -126
  18. data/doc-api/classes/Kwalify/MetaValidator.html +248 -232
  19. data/doc-api/classes/Kwalify/Parser.html +12 -12
  20. data/doc-api/classes/Kwalify/PlainYamlParser.html +166 -163
  21. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +11 -11
  22. data/doc-api/classes/Kwalify/Rule.html +152 -130
  23. data/doc-api/classes/Kwalify/SchemaError.html +10 -10
  24. data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
  25. data/doc-api/classes/Kwalify/Types.html +26 -25
  26. data/doc-api/classes/Kwalify/Util.html +389 -0
  27. data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
  28. data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
  29. data/doc-api/classes/Kwalify/ValidationError.html +10 -10
  30. data/doc-api/classes/Kwalify/Validator.html +153 -86
  31. data/doc-api/classes/Kwalify/Yaml.html +181 -0
  32. data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
  33. data/doc-api/classes/Kwalify/YamlParser.html +190 -183
  34. data/doc-api/classes/Kwalify/YamlSyntaxError.html +8 -57
  35. data/doc-api/created.rid +1 -1
  36. data/doc-api/files/__/README_txt.html +17 -22
  37. data/doc-api/files/kwalify/errors_rb.html +2 -2
  38. data/doc-api/files/kwalify/main_rb.html +4 -3
  39. data/doc-api/files/kwalify/messages_rb.html +2 -2
  40. data/doc-api/files/kwalify/meta-validator_rb.html +3 -3
  41. data/doc-api/files/kwalify/{util/yaml-helper_rb.html → parser/base_rb.html} +8 -6
  42. data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
  43. data/doc-api/files/kwalify/rule_rb.html +2 -2
  44. data/doc-api/files/kwalify/types_rb.html +2 -2
  45. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
  46. data/doc-api/files/kwalify/util/hash-interface_rb.html +9 -2
  47. data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
  48. data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
  49. data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
  50. data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
  51. data/doc-api/files/kwalify/util_rb.html +107 -0
  52. data/doc-api/files/kwalify/validator_rb.html +2 -2
  53. data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
  54. data/doc-api/files/kwalify_rb.html +3 -2
  55. data/doc-api/fr_class_index.html +8 -1
  56. data/doc-api/fr_file_index.html +5 -1
  57. data/doc-api/fr_method_index.html +128 -69
  58. data/doc/img/fig01.png +0 -0
  59. data/doc/users-guide.html +882 -717
  60. data/examples/address-book/address-book.schema.yaml +2 -2
  61. data/examples/data-binding/BABEL.data.yaml +63 -0
  62. data/examples/data-binding/BABEL.schema.yaml +31 -0
  63. data/examples/data-binding/Makefile +8 -0
  64. data/examples/data-binding/Rakefile +13 -0
  65. data/examples/data-binding/main.rb +27 -0
  66. data/examples/invoice/invoice.schema.yaml +3 -3
  67. data/examples/tapkit/tapkit.schema.yaml +2 -2
  68. data/lib/kwalify.rb +41 -4
  69. data/lib/kwalify/errors.rb +118 -96
  70. data/lib/kwalify/kwalify.schema.yaml +58 -0
  71. data/lib/kwalify/main.rb +384 -377
  72. data/lib/kwalify/messages.rb +41 -27
  73. data/lib/kwalify/meta-validator.rb +251 -331
  74. data/lib/kwalify/parser/base.rb +127 -0
  75. data/lib/kwalify/parser/yaml.rb +837 -0
  76. data/lib/kwalify/rule.rb +545 -487
  77. data/lib/kwalify/templates/genclass-java.eruby +189 -162
  78. data/lib/kwalify/templates/genclass-php.eruby +104 -0
  79. data/lib/kwalify/templates/genclass-ruby.eruby +95 -66
  80. data/lib/kwalify/types.rb +107 -106
  81. data/lib/kwalify/util.rb +157 -0
  82. data/lib/kwalify/util/assert-text-equal.rb +33 -31
  83. data/lib/kwalify/util/hash-interface.rb +11 -30
  84. data/lib/kwalify/util/hashlike.rb +51 -0
  85. data/lib/kwalify/util/option-parser.rb +144 -144
  86. data/lib/kwalify/util/ordered-hash.rb +57 -0
  87. data/lib/kwalify/util/testcase-helper.rb +3 -3
  88. data/lib/kwalify/validator.rb +267 -212
  89. data/lib/kwalify/yaml-parser.rb +822 -768
  90. data/setup.rb +861 -607
  91. data/test/Rookbook.yaml +10 -0
  92. data/test/{tmp.dir/Context.java → data/users-guide/AddressBook.java.expected} +11 -11
  93. data/test/data/users-guide/BABEL.data.yaml +24 -0
  94. data/test/data/users-guide/BABEL.schema.yaml +30 -0
  95. data/test/data/users-guide/ExampleAddressBook.java +47 -0
  96. data/test/{tmp.dir/Group.java → data/users-guide/Group.java.expected} +2 -11
  97. data/test/data/users-guide/Person.java.expected +44 -0
  98. data/test/data/users-guide/address_book.rb +52 -0
  99. data/test/data/users-guide/address_book.schema.yaml +28 -0
  100. data/test/data/users-guide/address_book.yaml +27 -0
  101. data/test/data/users-guide/answers-schema.yaml +12 -0
  102. data/test/data/users-guide/answers-validator.rb +52 -0
  103. data/test/data/users-guide/babel_genclass.result +26 -0
  104. data/test/data/users-guide/config.schema.yaml +7 -0
  105. data/test/data/users-guide/config.yaml +4 -0
  106. data/test/{tmp.dir/silent1.document → data/users-guide/document01a.yaml} +0 -0
  107. data/test/data/users-guide/document01b.yaml +3 -0
  108. data/test/data/users-guide/document02a.yaml +4 -0
  109. data/test/data/users-guide/document02b.yaml +4 -0
  110. data/test/data/users-guide/document03a.yaml +6 -0
  111. data/test/data/users-guide/document03b.yaml +6 -0
  112. data/test/data/users-guide/document04a.yaml +9 -0
  113. data/test/data/users-guide/document04b.yaml +9 -0
  114. data/test/data/users-guide/document05a.yaml +11 -0
  115. data/test/data/users-guide/document05b.yaml +12 -0
  116. data/test/data/users-guide/document06a.yaml +15 -0
  117. data/test/data/users-guide/document06b.yaml +16 -0
  118. data/test/data/users-guide/document07a.yaml +9 -0
  119. data/test/data/users-guide/document07b.yaml +7 -0
  120. data/test/data/users-guide/document12a.json +10 -0
  121. data/test/data/users-guide/document12b.json +6 -0
  122. data/test/data/users-guide/document13a.yaml +17 -0
  123. data/test/data/users-guide/document14a.yaml +3 -0
  124. data/test/data/users-guide/document14b.yaml +3 -0
  125. data/test/data/users-guide/document15a.yaml +6 -0
  126. data/test/data/users-guide/document15b.yaml +5 -0
  127. data/test/data/users-guide/example_address_book.rb +10 -0
  128. data/test/data/users-guide/example_address_book_java.result +32 -0
  129. data/test/data/users-guide/example_address_book_ruby.result +31 -0
  130. data/test/data/users-guide/genclass_java.result +4 -0
  131. data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
  132. data/test/data/users-guide/howto-validation.rb +25 -0
  133. data/test/data/users-guide/howto3.rb +6 -0
  134. data/test/data/users-guide/howto3.result +5 -0
  135. data/test/data/users-guide/howto3.yaml +8 -0
  136. data/test/data/users-guide/howto5_databinding.result +111 -0
  137. data/test/data/users-guide/invalid01.result +3 -0
  138. data/test/data/users-guide/invalid02.result +5 -0
  139. data/test/data/users-guide/invalid03.result +5 -0
  140. data/test/data/users-guide/invalid04.result +4 -0
  141. data/test/data/users-guide/invalid05.result +11 -0
  142. data/test/data/users-guide/invalid06.result +4 -0
  143. data/test/data/users-guide/invalid07.result +3 -0
  144. data/test/data/users-guide/invalid08.result +3 -0
  145. data/test/data/users-guide/invalid12.json +8 -0
  146. data/test/data/users-guide/invalid14.result +4 -0
  147. data/test/data/users-guide/invalid15.result +4 -0
  148. data/test/data/users-guide/loadbabel.rb +27 -0
  149. data/test/data/users-guide/loadconfig.rb +15 -0
  150. data/test/data/users-guide/loadconfig.result +2 -0
  151. data/test/data/users-guide/models.rb +22 -0
  152. data/test/data/users-guide/option_ha.result +6 -0
  153. data/test/data/users-guide/option_ha_genclass_java.result +7 -0
  154. data/test/{tmp.dir/meta1.schema → data/users-guide/schema01.yaml} +0 -0
  155. data/test/data/users-guide/schema02.yaml +12 -0
  156. data/test/data/users-guide/schema03.yaml +9 -0
  157. data/test/data/users-guide/schema04.yaml +20 -0
  158. data/test/data/users-guide/schema05.yaml +29 -0
  159. data/test/data/users-guide/schema06.yaml +11 -0
  160. data/test/data/users-guide/schema12.json +12 -0
  161. data/test/data/users-guide/schema13.yaml +13 -0
  162. data/test/data/users-guide/schema14.yaml +5 -0
  163. data/test/data/users-guide/schema15.yaml +21 -0
  164. data/test/data/users-guide/valid01.result +2 -0
  165. data/test/data/users-guide/valid02.result +2 -0
  166. data/test/data/users-guide/valid03.result +2 -0
  167. data/test/data/users-guide/valid04.result +2 -0
  168. data/test/data/users-guide/valid05.result +2 -0
  169. data/test/data/users-guide/valid06.result +2 -0
  170. data/test/data/users-guide/valid07.result +2 -0
  171. data/test/data/users-guide/valid08.result +2 -0
  172. data/test/data/users-guide/valid12.result +2 -0
  173. data/test/data/users-guide/valid13.result +2 -0
  174. data/test/data/users-guide/valid14.result +2 -0
  175. data/test/data/users-guide/valid15.result +2 -0
  176. data/test/data/users-guide/validate08.rb +37 -0
  177. data/test/test-action.rb +78 -0
  178. data/test/test-action.yaml +738 -0
  179. data/test/test-databinding.rb +80 -0
  180. data/test/test-databinding.yaml +301 -0
  181. data/test/test-main.rb +129 -150
  182. data/test/test-main.yaml +126 -321
  183. data/test/test-metavalidator.rb +47 -47
  184. data/test/test-metavalidator.yaml +77 -21
  185. data/test/test-parser-yaml.rb +57 -0
  186. data/test/test-parser-yaml.yaml +1749 -0
  187. data/test/test-rule.rb +14 -15
  188. data/test/test-rule.yaml +6 -3
  189. data/test/test-users-guide.rb +75 -0
  190. data/test/test-validator.rb +77 -52
  191. data/test/test-validator.yaml +168 -6
  192. data/test/test-yaml-parser.rb +47 -0
  193. data/test/{test-yamlparser.yaml → test-yaml-parser.yaml} +159 -52
  194. data/test/test.rb +37 -21
  195. metadata +136 -37
  196. data/COPYING +0 -340
  197. data/ChangeLog +0 -70
  198. data/doc-api/classes/YamlHelper.html +0 -259
  199. data/lib/kwalify/util/yaml-helper.rb +0 -82
  200. data/test/test-yamlparser.rb +0 -58
  201. data/test/tmp.dir/User.java +0 -43
  202. data/test/tmp.dir/action1.document +0 -18
  203. data/test/tmp.dir/action1.schema +0 -32
  204. data/test/tmp.dir/action2.document +0 -18
  205. data/test/tmp.dir/action2.schema +0 -32
  206. data/test/tmp.dir/emacs.document +0 -6
  207. data/test/tmp.dir/emacs.schema +0 -6
  208. data/test/tmp.dir/meta1.document +0 -0
  209. data/test/tmp.dir/meta2.document +0 -0
  210. data/test/tmp.dir/meta2.schema +0 -3
  211. data/test/tmp.dir/silent1.schema +0 -3
  212. data/test/tmp.dir/silent2.document +0 -7
  213. data/test/tmp.dir/silent2.schema +0 -3
  214. data/test/tmp.dir/stream.invalid +0 -8
  215. data/test/tmp.dir/stream.schema +0 -3
  216. data/test/tmp.dir/stream.valid +0 -8
  217. data/test/tmp.dir/untabify.document +0 -5
  218. data/test/tmp.dir/untabify.schema +0 -10
  219. data/todo.txt +0 -34
@@ -0,0 +1,47 @@
1
+ ###
2
+ ### $Rev: 83 $
3
+ ### $Release: 0.7.0 $
4
+ ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
+ ###
6
+
7
+ require File.dirname(__FILE__) + '/test.rb'
8
+
9
+
10
+ class ParserTest < Test::Unit::TestCase
11
+
12
+ filename = __FILE__.sub(/\.rb$/, '.yaml')
13
+ load_yaml_testdata(filename, :lang=>'ruby')
14
+
15
+ def _test()
16
+ if @exception
17
+ @error_class = @exception.split(/::/).inject(Kernel) { |k,s| k = k.const_get(s) }
18
+ #@error_class = Kwalify::YamlSyntaxError if @error_class == Kwalify::SyntaxError
19
+ end
20
+ parser = Kwalify::YamlParser.new(@input)
21
+ if @error_class
22
+ assert_raise(@error_class) do
23
+ doc = parser.parse()
24
+ end
25
+ else
26
+ doc = parser.parse()
27
+ #if @recursive || @pp
28
+ if @testopts && (@testopts['recursive'] || @testopts['pp'])
29
+ s = StringWriter.new
30
+ PP.pp(doc, s)
31
+ actual = s
32
+ else
33
+ actual = doc.inspect + "\n"
34
+ end
35
+ if $log
36
+ File.open("#{@name}.expected", 'w') { |f| f.write(@expected) }
37
+ File.open("#{@name}.actual", 'w') { |f| f.write(actual) }
38
+ end
39
+ if $print
40
+ print actual
41
+ else
42
+ assert_text_equal(@expected, actual)
43
+ end
44
+ end
45
+ end
46
+
47
+ end
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 50 $
3
- ## $Release: 0.6.1 $
4
- ## copyright(c) 2005 kuwata-lab all rights reserved.
2
+ ## $Rev: 92 $
3
+ ## $Release: 0.7.0 $
4
+ ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
5
  ##
6
6
  ---
7
7
  name: sequence1
@@ -27,7 +27,7 @@ input: |
27
27
  - C
28
28
  expected: |
29
29
  ["A", ["B1", "B2", ["B2.1", "B2.2"]], "C"]
30
- #
30
+ ##
31
31
  ---
32
32
  name: sequence3
33
33
  desc: null item of sequence
@@ -41,7 +41,7 @@ input: |
41
41
  - G
42
42
  expected: |
43
43
  ["A", nil, "C", nil, nil, nil, "G"]
44
- #
44
+ ##
45
45
  ---
46
46
  name: sequence4
47
47
  desc: null item of nested sequence
@@ -56,7 +56,7 @@ input: |
56
56
  #
57
57
  expected: |
58
58
  [[[nil, nil, nil]], nil]
59
- #
59
+ ##
60
60
  ---
61
61
  name: sequence5
62
62
  desc: sequence with empty lines
@@ -73,11 +73,11 @@ input: |
73
73
  -
74
74
  expected: |
75
75
  ["A", ["B"], nil]
76
- #
76
+ ##
77
77
  ---
78
78
  name: sequence6
79
79
  desc: syntax error - invalid indent of sequence.
80
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
80
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
81
81
  #
82
82
  input: |
83
83
  - AAA
@@ -86,11 +86,11 @@ input: |
86
86
  - CCC
87
87
  #
88
88
  expected: |
89
- #
89
+ ##
90
90
  ---
91
91
  name: sequence7
92
92
  desc: syntax error - sequence item is exepcted.
93
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
93
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
94
94
  input: |
95
95
  -
96
96
  - a1
@@ -161,7 +161,7 @@ expected: |
161
161
  ---
162
162
  name: mapping5
163
163
  desc: parse error - invalid indent of mapping.
164
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
164
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
165
165
  input: |
166
166
  A: 10
167
167
  B: 20
@@ -173,7 +173,7 @@ expected: |
173
173
  ---
174
174
  name: mapping6
175
175
  desc: parse error - mapping item is expected.
176
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
176
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
177
177
  input: |
178
178
  A:
179
179
  a1: 1
@@ -266,10 +266,10 @@ input: |
266
266
  A: a: 1: 100
267
267
  2: 200
268
268
  B: b: 3: 300
269
- 4: 400
269
+ "4": 400
270
270
  #
271
271
  expected: |
272
- {"A"=>{"a"=>{1=>100, 2=>200}}, "B"=>{"b"=>{3=>300, 4=>400}}}
272
+ {"A"=>{"a"=>{1=>100, 2=>200}}, "B"=>{"b"=>{3=>300, "4"=>400}}}
273
273
  ##
274
274
  ---
275
275
  name: comment1
@@ -300,7 +300,7 @@ input: |
300
300
  #
301
301
  expected: |
302
302
  ["A", {"B"=>"# comment"}, "# comment"]
303
- #
303
+ ##
304
304
  ---
305
305
  name: comment3
306
306
  desc: line comment with seq and map
@@ -313,7 +313,7 @@ input: |
313
313
  #
314
314
  expected: |
315
315
  ["A", {"B"=>{"C"=>"foo", "D"=>"bar#bar"}}]
316
- #
316
+ ##
317
317
  ---
318
318
  name: comment4
319
319
  desc: line comment with anchor and alias
@@ -325,7 +325,7 @@ input: |
325
325
  #
326
326
  expected: |
327
327
  ["foo", "foo"]
328
- #
328
+ ##
329
329
  ---
330
330
  name: flowseq1
331
331
  desc: flow style sequence
@@ -336,6 +336,7 @@ input: |
336
336
  #
337
337
  expected: |
338
338
  [[10, 20], [15, 25, 35]]
339
+ # [[10, 20], ["15,25,35"]]
339
340
  ##
340
341
  ---
341
342
  name: flowseq2
@@ -343,14 +344,14 @@ desc: nested flow style sequence
343
344
  #
344
345
  input: |
345
346
  1: [ A, [B1, B2]]
346
- 2: [[[X]]]
347
- 3: [[1,1],[2,"2"],['3',3]]
347
+ '2': [[[X]]]
348
+ 3: [[1, 1], [2, "2"], ['3', 3]]
348
349
  #
349
350
  expected: |
350
- {1=>["A", ["B1", "B2"]], 2=>[[["X"]]], 3=>[[1, 1], [2, "2"], ["3", 3]]}
351
+ {1=>["A", ["B1", "B2"]], "2"=>[[["X"]]], 3=>[[1, 1], [2, "2"], ["3", 3]]}
351
352
  #expected: |
352
353
  # {1=>["A", ["B1", "B2"]],
353
- # 2=>[[["X"]]],
354
+ # "2"=>[[["X"]]],
354
355
  # 3=>[["x1", "y1"], ["x2", "y2"], ["x3", "y3"]]}
355
356
  ##
356
357
  ---
@@ -358,9 +359,9 @@ name: flowseq3
358
359
  desc: flow style sequence with some lines
359
360
  #
360
361
  input: |
361
- A: [ [10,20],
362
- [11,21],
363
- [12,22]]
362
+ A: [ [10, 20],
363
+ [11, 21],
364
+ [12, 22]]
364
365
  B: [
365
366
  [1.1,
366
367
  1.2,
@@ -375,30 +376,30 @@ expected: |
375
376
  name: flowseq4
376
377
  desc: invalid flow style seq (sequence item required (or last comma is extra).)
377
378
  mesg: sequence item required (or last comma is extra).
378
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
379
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
379
380
  #
380
381
  input: |
381
382
  A: [ [10,20], ]
382
383
  #
383
384
  expected: |
384
- #
385
+ ##
385
386
  ---
386
387
  name: flowseq5
387
388
  desc: invalid flow style seq (flow style sequence requires ']').
388
389
  mesg: flow style sequence requires ']'
389
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
390
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
390
391
  #
391
392
  input: |
392
393
  A: [ [10,20]
393
394
  B: [ [30, 40]]
394
395
  #
395
396
  expected: |
396
- #
397
+ ##
397
398
  ---
398
399
  name: flowseq6
399
400
  desc: invalid flow style seq (flow style sequence requires ']').
400
401
  mesg: flow style sequence is closed but got ']'.
401
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
402
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
402
403
  #
403
404
  input: |
404
405
  [ 10 ]]
@@ -415,14 +416,14 @@ input: |
415
416
  #
416
417
  expected: |
417
418
  [{"A1"=>10, "A2"=>20}, {"B1"=>15, "B2"=>25, "B3"=>35}]
418
- #
419
+ ##
419
420
  ---
420
421
  name: flowmap2
421
422
  desc: flow style map nested
422
423
  #
423
424
  input: |
424
425
  A: { x: {y: {z: 10}}}
425
- B: { a: 1, b:{c: 2, d: 3, e:{f: 4}}, g: 5}
426
+ B: { a: 1, b: {c: 2, d: 3, e: {f: 4}}, g: 5}
426
427
  #
427
428
  expected: |
428
429
  {"A"=>{"x"=>{"y"=>{"z"=>10}}}, "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
@@ -462,30 +463,30 @@ expected: |
462
463
  name: flowmap4
463
464
  desc: invalid flow style map (mapping item required (or last comma is extra).)
464
465
  mesg: mapping item required (or last comma is extra).
465
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
466
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
466
467
  #
467
468
  input: |
468
469
  - {A: 10, B: 20, }
469
470
  #
470
471
  expected: |
471
- #
472
+ ##
472
473
  ---
473
474
  name: flowmap5
474
475
  desc: invalid flow style map (flow style mapping requires '}').
475
476
  mesg: flow style mapping requires '}'
476
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
477
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
477
478
  #
478
479
  input: |
479
480
  - {A: { x: 10, y: 20 }
480
481
  - {A: { x: 11, y: 21 }}
481
482
  #
482
483
  expected: |
483
- #
484
+ ##
484
485
  ---
485
486
  name: flowmap6
486
487
  desc: invalid flow style map (flow style mapping requires ']').
487
488
  mesg: flow style mapping is closed but got '}'.
488
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
489
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
489
490
  #
490
491
  input: |
491
492
  { x: 10 }}
@@ -655,7 +656,7 @@ expected: |
655
656
  #---
656
657
  #name: blocktext06
657
658
  #desc: invalid block text
658
- #exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
659
+ #exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
659
660
  ##
660
661
  #input: |
661
662
  # - |
@@ -750,7 +751,7 @@ input: |
750
751
  expected: |
751
752
  [" A\n B C\n", " A\n B C\n\n\n", " A\n B C"]
752
753
  # [" A\n\n B\n C\n", " A\n\n B\n C\n\n\n", " A\n\n B\n C"]
753
- #
754
+ ##
754
755
  ---
755
756
  name: blocktext14
756
757
  desc: block text with '> foo'
@@ -769,7 +770,7 @@ input: |
769
770
  #
770
771
  expected: |
771
772
  [{"text1"=>"foo A\nB C\n"}, "fooA B C\n"]
772
- #
773
+ ##
773
774
  ---
774
775
  name: blocktext15
775
776
  desc: block text with '#' (comment)
@@ -799,11 +800,11 @@ input: |
799
800
  #
800
801
  expected: |
801
802
  [{"text1"=>"AA ## BB\n", "text2"=>"# #\n"}, "AA ## BB\n", "# #\n", "x"]
802
- #
803
+ ##
803
804
  #---
804
805
  #name: blocktext16
805
806
  #desc: invalid block text
806
- #exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
807
+ #exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
807
808
  ##
808
809
  #input: |
809
810
  # - >
@@ -826,7 +827,7 @@ input: |
826
827
  #
827
828
  expected: |
828
829
  ["foo", "bar", "foo", "bar"]
829
- #
830
+ ##
830
831
  ---
831
832
  name: anchor2
832
833
  desc: parse_anchor, parse_alias
@@ -840,11 +841,11 @@ input: |
840
841
  #
841
842
  expected: |
842
843
  [{"A"=>{"x"=>10, "y"=>20}}, {"B"=>"bar"}, {"C"=>{"x"=>10, "y"=>20}}]
843
- #
844
+ ##
844
845
  ---
845
846
  name: anchor3
846
847
  desc: anchor on child node
847
- recursive: yes
848
+ testopts: { recursive: yes }
848
849
  #
849
850
  input: |
850
851
  - A: &a1
@@ -857,7 +858,7 @@ expected: |
857
858
  ##
858
859
  ---
859
860
  name: anchor4
860
- desc: backward anchor
861
+ desc: preceding anchor
861
862
  #
862
863
  input: |
863
864
  - *a1
@@ -871,8 +872,8 @@ expected: |
871
872
  ---
872
873
  name: anchor5
873
874
  desc: anchor not found
874
- exception*: { ruby: YamlSyntaxError, java: kwalify.SyntaxException }
875
- mesg: anchor 'a2' not found (YamlSyntaxError)
875
+ exception*: { ruby: Kwalify::YamlSyntaxError, java: kwalify.SyntaxException }
876
+ mesg: anchor 'a2' not found (Kwalify::YamlSyntaxError)
876
877
  #
877
878
  input: |
878
879
  - &a1 foo
@@ -884,7 +885,7 @@ expected: |
884
885
  ---
885
886
  name: anchor6
886
887
  desc: anchor on child node
887
- recursive: yes
888
+ testopts: { recursive: yes }
888
889
  #
889
890
  input: |
890
891
  type: seq
@@ -915,6 +916,109 @@ expected*:
915
916
  {"sequence"=>[{"mapping"=>{"name"=>{"type"=>"str"}, "post"=>{"enum"=>["exective", "manager", "clerk"], "type"=>"str"}, "supervisor"=>{...}}, "type"=>"map"}], "type"=>"seq"}
916
917
  ##
917
918
  ---
919
+ name: anchor7
920
+ desc: anchor and alias with flow style data
921
+ #
922
+ input: |
923
+ - &a1 {v: &a2 [1, 2, 3]}
924
+ - [x, *a1, y]
925
+ - {z: *a2}
926
+ #
927
+ expected*:
928
+ ruby: |
929
+ [{"v"=>[1, 2, 3]}, ["x", {"v"=>[1, 2, 3]}, "y"], {"z"=>[1, 2, 3]}]
930
+ java: |
931
+ [{"v"=>[1, 2, 3]}, ["x", {"v"=>[1, 2, 3]}, "y"], {"z"=>[1, 2, 3]}]
932
+ ##
933
+ ---
934
+ name: anchor8
935
+ desc: recursive alias with flow style data
936
+ testopts: { recursive: yes }
937
+ #
938
+ input: |
939
+ - &a1
940
+ {v: &a2 [*a1, *a2]}
941
+ #
942
+ expected*:
943
+ ruby: |
944
+ [{"v"=>[{...}, [...]]}]
945
+ java: |
946
+ [{"v"=>[{...}, [...]]}]
947
+ ##
948
+ ---
949
+ name: preceding1
950
+ desc: preceding anchor
951
+ testopts: { allow_preceding_alias: yes }
952
+ #
953
+ input: |
954
+ - *a1
955
+ - &a1 AAA
956
+ #
957
+ expected*:
958
+ ruby: |
959
+ ["AAA", "AAA"]
960
+ java: |
961
+ ["AAA", "AAA"]
962
+ ##
963
+ ---
964
+ name: preceding2
965
+ desc: preceding anchor
966
+ testopts: { allow_preceding_alias: yes, pp: yes }
967
+ #
968
+ input: |
969
+ groups:
970
+ - name: wheel
971
+ owner: *ROOT
972
+ - name: users
973
+ owner: *USER1
974
+
975
+ users:
976
+ - &ROOT
977
+ name: root
978
+ email: root@localhost
979
+ - &USER1
980
+ name: user1
981
+ email: user1@localhost
982
+ #
983
+ expected*:
984
+ ruby: |
985
+ {"groups"=>
986
+ [{"name"=>"wheel", "owner"=>{"name"=>"root", "email"=>"root@localhost"}},
987
+ {"name"=>"users", "owner"=>{"name"=>"user1", "email"=>"user1@localhost"}}],
988
+ "users"=>
989
+ [{"name"=>"root", "email"=>"root@localhost"},
990
+ {"name"=>"user1", "email"=>"user1@localhost"}]}
991
+ java: |
992
+ ##
993
+ ---
994
+ name: preceding3
995
+ desc: preceding anchor not found
996
+ testopts: { allow_preceding_alias: yes }
997
+ #
998
+ input: |
999
+ groups:
1000
+ - name: wheel
1001
+ owner: *ROOT
1002
+ - name: users
1003
+ owner: *USER1
1004
+
1005
+ users:
1006
+ - &ROOT
1007
+ name: root
1008
+ email: root@localhost
1009
+ - &USER2
1010
+ name: user1
1011
+ email: user1@localhost
1012
+ #
1013
+ exception*:
1014
+ ruby: Kwalify::YamlSyntaxError
1015
+ #java: kwalify.SyntaxError
1016
+ errormsg*:
1017
+ ruby: "*USER1: anchor not found."
1018
+ #java: "*USER1: anchor not found."
1019
+ location: { linenum: 5, column: 13 }
1020
+ ##
1021
+ ---
918
1022
  name: tag1
919
1023
  desc: tag
920
1024
  #
@@ -937,7 +1041,7 @@ input: |
937
1041
  #
938
1042
  expected: |
939
1043
  ["aaa", "bbb"]
940
- #
1044
+ ##
941
1045
  ---
942
1046
  name: docend2
943
1047
  desc: ... (document end) in block text
@@ -1066,7 +1170,7 @@ expected*:
1066
1170
  ---
1067
1171
  name: scalar2
1068
1172
  desc: mapping of scalar
1069
- pp: yes
1173
+ testopts: { pp: yes }
1070
1174
  input: |
1071
1175
  - abc : ABC
1072
1176
  - 123 : 123
@@ -1081,7 +1185,8 @@ input: |
1081
1185
  - '456' : '456'
1082
1186
  - 2005-01-01 : 2005-01-01
1083
1187
  - :sym : :sym
1084
- # - ~ : ~
1188
+ # - ~ : ~
1189
+ # - 2005-01-01 00:00:00 : 2005-01-01 00:00:00
1085
1190
  expected*:
1086
1191
  ruby: |
1087
1192
  [{"abc"=>"ABC"},
@@ -1101,7 +1206,6 @@ expected*:
1101
1206
  [{"abc"=>"ABC"}, {123=>123}, {3.14=>3.14}, {true=>true}, {false=>false}, {true=>true}, {false=>false}, "~ : ~", {nil=>nil}, {"123"=>"123"}, {"456"=>"456"}, {Tue Feb 01 00:00:00 JST 2005=>Tue Feb 01 00:00:00 JST 2005}, {":sym"=>":sym"}]
1102
1207
  # {123=>1.23, 3.14=>314, "abc"=>"ABC"}
1103
1208
  # {"abc"=>"ABC", 3.14=>314, 123=>1.23}
1104
-
1105
1209
  ##
1106
1210
  ---
1107
1211
  name: mapkey1
@@ -1117,3 +1221,6 @@ expected*:
1117
1221
  [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}]
1118
1222
  # [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}, {"k:e:y:5"=>"E"}]
1119
1223
  java: |
1224
+ [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}]
1225
+ # [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}, {"k:e:y:5"=>"E"}]
1226
+ ##