kwalify 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 51 $
3
- ### $Release: 0.6.1 $
4
- ### copyright(c) 2005 kuwata-lab all rights reserved.
2
+ ### $Rev: 83 $
3
+ ### $Release: 0.7.0 $
4
+ ### copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require File.dirname(__FILE__) + '/test.rb'
@@ -9,14 +9,14 @@ require File.dirname(__FILE__) + '/test.rb'
9
9
 
10
10
  class MetaValidatorTest < Test::Unit::TestCase
11
11
 
12
- ## define test methods
13
- filename = __FILE__.sub(/\.rb$/, '.yaml')
14
- load_yaml_documents(filename) do |ydoc|
15
- name = ydoc['name']
16
- ydoc.each do |key, val|
17
- ydoc[$1] = val['ruby'] if key =~ /(.*)\*$/
18
- end
19
- s = <<-END
12
+ ## define test methods
13
+ filename = __FILE__.sub(/\.rb$/, '.yaml')
14
+ load_yaml_documents(filename) do |ydoc|
15
+ name = ydoc['name']
16
+ ydoc.each do |key, val|
17
+ ydoc[$1] = val['ruby'] if key =~ /(.*)\*$/
18
+ end
19
+ s = <<-END
20
20
  def test_meta_#{name}
21
21
  @name = #{ydoc['name'].inspect}
22
22
  @desc = #{ydoc['desc'].inspect}
@@ -27,8 +27,8 @@ class MetaValidatorTest < Test::Unit::TestCase
27
27
  _test
28
28
  end
29
29
  END
30
- module_eval s if ydoc['meta-msg']
31
- s = <<-END
30
+ module_eval s if ydoc['meta-msg']
31
+ s = <<-END
32
32
  def test_rule_#{name}
33
33
  @name = #{ydoc['name'].inspect}
34
34
  @desc = #{ydoc['desc'].inspect}
@@ -39,42 +39,42 @@ class MetaValidatorTest < Test::Unit::TestCase
39
39
  _test
40
40
  end
41
41
  END
42
- module_eval s if ydoc['rule-msg']
43
- end
42
+ module_eval s if ydoc['rule-msg']
43
+ end
44
44
 
45
45
 
46
- ## execute test
47
- def _test()
48
- return if $target && $target != @name
49
- #schema = YAML.load(@schema)
50
- parser = Kwalify::YamlParser.new(@schema)
51
- schema = parser.parse()
52
- case @test_type
53
- when :meta
54
- meta_validator = Kwalify::MetaValidator.instance()
55
- errors = meta_validator.validate(schema)
56
- parser.set_errors_linenum(errors)
57
- errors.sort!
58
- expected = @meta_msg
59
- when :rule
60
- errors = []
61
- begin
62
- rule = Kwalify::Validator.new(schema)
63
- rescue Kwalify::KwalifyError => error
64
- errors << error
65
- end
66
- expected = @rule_msg
67
- end
68
- actual = ''
69
- errors.each do |error|
70
- raise error if error.is_a?(Kwalify::AssertionError)
71
- actual << "%-20s: [%s] %s\n" % [error.error_symbol.inspect, error.path, error.message]
72
- end
73
- if $print
74
- print actual
75
- else
76
- assert_text_equal(expected, actual)
46
+ ## execute test
47
+ def _test()
48
+ return if $target && $target != @name
49
+ #schema = YAML.load(@schema)
50
+ parser = Kwalify::YamlParser.new(@schema)
51
+ schema = parser.parse()
52
+ case @test_type
53
+ when :meta
54
+ meta_validator = Kwalify::MetaValidator.instance()
55
+ errors = meta_validator.validate(schema)
56
+ parser.set_errors_linenum(errors)
57
+ errors.sort!
58
+ expected = @meta_msg
59
+ when :rule
60
+ errors = []
61
+ begin
62
+ rule = Kwalify::Validator.new(schema)
63
+ rescue Kwalify::KwalifyError => error
64
+ errors << error
77
65
  end
78
- end
66
+ expected = @rule_msg
67
+ end
68
+ actual = ''
69
+ errors.each do |error|
70
+ raise error if error.is_a?(Kwalify::AssertionError)
71
+ actual << "%-20s: [%s] %s\n" % [error.error_symbol.inspect, error.path, error.message]
72
+ end
73
+ if $print
74
+ print actual
75
+ else
76
+ assert_text_equal(expected, actual)
77
+ end
78
+ end
79
79
 
80
80
  end
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 51 $
3
- ## $Release: 0.6.1 $
4
- ## copyright(c) 2005 kuwata-lab all rights reserved.
2
+ ## $Rev: 95 $
3
+ ## $Release: 0.7.0 $
4
+ ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
5
  ##
6
6
  ---
7
7
  name: schema_notmap
@@ -1103,21 +1103,77 @@ rule-msg: |
1103
1103
  :ident_notmap : [/sequence/0/mapping/values/sequence/0] 'ident:': is available only with an element of mapping.
1104
1104
  #
1105
1105
  ---
1106
- name: classname_notmap
1107
- desc: classname_notmap
1108
- schema: |
1109
- type: map
1110
- classname: User
1111
- mapping:
1112
- "name": { type: str, required: yes }
1113
- "email": { type: str }
1114
- "phones":
1115
- type: seq
1116
- classname: Phone
1117
- sequence:
1118
- - type: str
1119
-
1120
- meta-msg: |
1121
- :classname_notmap : [/mapping/phones/classname] 'classname:': available only with map type.
1122
- rule-msg: |
1123
- :classname_notmap : [/mapping/phones/classname] 'classname:': available only with map type.
1106
+ name: class_notmap
1107
+ desc: class_notmap
1108
+ schema: |
1109
+ type: map
1110
+ class: User
1111
+ mapping:
1112
+ "name": { type: str, required: yes }
1113
+ "email": { type: str }
1114
+ "phones":
1115
+ type: seq
1116
+ class: Phone
1117
+ sequence:
1118
+ - type: str
1119
+
1120
+ meta-msg: |
1121
+ :class_notmap : [/mapping/phones/class] 'class:': available only with map type.
1122
+ rule-msg: |
1123
+ :class_notmap : [/mapping/phones/class] 'class:': available only with map type.
1124
+ #
1125
+ ---
1126
+ name: default_nonscalarval
1127
+ desc: value is not a scalar
1128
+ schema: |
1129
+ type: map
1130
+ mapping:
1131
+ "deleted":
1132
+ type: any
1133
+ default: [ null ]
1134
+ meta-msg: |
1135
+ :type_unmatch : [/mapping/deleted/default] not a scalar.
1136
+ rule-msg: |
1137
+ :default_nonscalarval: [/mapping/deleted/default] not a scalar.
1138
+ #
1139
+ ---
1140
+ name: default_notscalar
1141
+ desc: "'default:' is not available with container"
1142
+ schema: |
1143
+ type: map
1144
+ default: null
1145
+ mapping:
1146
+ "=":
1147
+ meta-msg: |
1148
+ :default_notscalar : [/] 'default:': is available only with a scalar type.
1149
+ rule-msg: |
1150
+ :default_notscalar : [/] 'default:': is available only with a scalar type.
1151
+ #
1152
+ ---
1153
+ name: default_conflict
1154
+ desc: "'default:' is not available when 'required:' is true"
1155
+ schema: |
1156
+ type: map
1157
+ mapping:
1158
+ "name":
1159
+ type: str
1160
+ required: true
1161
+ default: ''
1162
+ meta-msg: |
1163
+ :default_conflict : [/mapping/name] 'default:': not available when 'required:' is true.
1164
+ rule-msg: |
1165
+ :default_conflict : [/mapping/name] 'default:': not available when 'required:' is true.
1166
+ #
1167
+ ---
1168
+ name: default_unmatch
1169
+ desc: "'default:' value is not matched to the type"
1170
+ schema: |
1171
+ type: map
1172
+ mapping:
1173
+ "name":
1174
+ type: str
1175
+ default: 123
1176
+ meta-msg: |
1177
+ :default_unmatch : [/mapping/name/default] '123': not a string.
1178
+ rule-msg: |
1179
+ :default_unmatch : [/mapping/name/default] '123': not a string.
@@ -0,0 +1,57 @@
1
+ ###
2
+ ### $Rev: 84 $
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
+
11
+ class YamlParserTest < Test::Unit::TestCase
12
+
13
+ filename = __FILE__.sub(/\.rb$/, '.yaml')
14
+ load_yaml_testdata(filename, :lang=>'ruby')
15
+
16
+ def _test()
17
+ if @exception
18
+ @error_class = @exception.split(/::/).inject(Kernel) { |c,s| c = c.const_get(s) }
19
+ end
20
+ parser = Kwalify::Yaml::Parser.new()
21
+ @testopts ||= {}
22
+ parser.preceding_alias = true if @testopts['preceding_alias']
23
+ if @error_class
24
+ ex = assert_raise(@error_class) do
25
+ doc = parser.parse(@input)
26
+ end
27
+ else
28
+ doc = parser.parse(@input)
29
+ if @testopts['pp'] || @testopts['recursive']
30
+ s = StringWriter.new
31
+ PP.pp(doc, s)
32
+ actual = s
33
+ else
34
+ actual = doc.inspect + "\n"
35
+ end
36
+ if $log
37
+ File.open("#{@name}.expected", 'w') { |f| f.write(@expected) }
38
+ File.open("#{@name}.actual", 'w') { |f| f.write(actual) }
39
+ end
40
+ if $print
41
+ print actual
42
+ else
43
+ assert_text_equal(@expected, actual)
44
+ #t = parser.instance_variable_get("@location_table")
45
+ #require 'pp'
46
+ if @locations
47
+ @locations.each do |path, expected_linenum, expected_column|
48
+ linenum, column = parser.location(path)
49
+ assert_equal(expected_linenum, linenum)
50
+ assert_equal(expected_column, column)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,1749 @@
1
+ ##
2
+ ## $Rev: 59 $
3
+ ## $Release: 0.7.0 $
4
+ ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
+ ##
6
+ ---
7
+ name: sequence1
8
+ desc: basic sequence
9
+ input: |
10
+ - aaa
11
+ - bbb
12
+ - ccc
13
+ expected: |
14
+ ["aaa", "bbb", "ccc"]
15
+ locations:
16
+ - [ "/", 1, 1 ]
17
+ - [ "/0", 1, 3 ]
18
+ - [ "/1", 2, 3 ]
19
+ - [ "/2", 3, 3 ]
20
+ ##
21
+ ---
22
+ name: sequence2
23
+ desc: nested sequence
24
+ input: |
25
+ - A
26
+ -
27
+ - B1
28
+ - B2
29
+ -
30
+ - B2.1
31
+ - B2.2
32
+ - C
33
+ expected: |
34
+ ["A", ["B1", "B2", ["B2.1", "B2.2"]], "C"]
35
+ locations:
36
+ - [ "/", 1, 1 ]
37
+ - [ "/0", 1, 3 ]
38
+ - [ "/1", 3, 3 ]
39
+ - [ "/1/0", 3, 5 ]
40
+ - [ "/1/1", 4, 5 ]
41
+ - [ "/1/2", 6, 5 ]
42
+ - [ "/1/2/0", 6, 7 ]
43
+ - [ "/1/2/1", 7, 7 ]
44
+ - [ "/2", 8, 3 ]
45
+ ##
46
+ ---
47
+ name: sequence3
48
+ desc: null item of sequence
49
+ input: |
50
+ - A
51
+ -
52
+ - C
53
+ -
54
+ -
55
+ -
56
+ - G
57
+ expected: |
58
+ ["A", nil, "C", nil, nil, nil, "G"]
59
+ locations:
60
+ - [ "/", 1, 1 ]
61
+ - [ "/0", 1, 3 ]
62
+ - [ "/1", 3, 1 ]
63
+ - [ "/2", 3, 3 ]
64
+ - [ "/3", 5, 1 ]
65
+ - [ "/6", 7, 3 ]
66
+ ##
67
+ ---
68
+ name: sequence4
69
+ desc: null item of nested sequence
70
+ #
71
+ input: |
72
+ -
73
+ -
74
+ -
75
+ -
76
+ -
77
+ -
78
+ #
79
+ expected: |
80
+ [[[nil, nil, nil]], nil]
81
+ locations:
82
+ - [ "/", 1, 1 ]
83
+ - [ "/0", 2, 3 ]
84
+ - [ "/0/0", 3, 5 ]
85
+ - [ "/0/0/0", 4, 5 ]
86
+ - [ "/1", 7, 1 ]
87
+ ##
88
+ ---
89
+ name: sequence5
90
+ desc: sequence with empty lines
91
+ input: |
92
+
93
+ - A
94
+
95
+ -
96
+
97
+
98
+ - B
99
+
100
+
101
+ -
102
+ expected: |
103
+ ["A", ["B"], nil]
104
+ locations:
105
+ - [ "/", 2, 1 ]
106
+ - [ "/0", 2, 3 ]
107
+ - [ "/1", 7, 5 ]
108
+ - [ "/2", 11, 1 ]
109
+ ##
110
+ ---
111
+ name: sequence6
112
+ desc: syntax error - invalid indent of sequence.
113
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
114
+ #
115
+ input: |
116
+ - AAA
117
+ - BBB1
118
+ - BBB2
119
+ - CCC
120
+ #
121
+ expected: |
122
+ locations:
123
+ ##
124
+ ---
125
+ name: sequence7
126
+ desc: syntax error - sequence item is exepcted.
127
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
128
+ input: |
129
+ -
130
+ - a1
131
+ - a2
132
+ a3
133
+ -
134
+ - b1
135
+ - b2
136
+ b3
137
+ expected: |
138
+ locations:
139
+ ##
140
+ ---
141
+ name: mapping1
142
+ desc: basic mapping
143
+ input: |
144
+ A: foo
145
+ B: bar
146
+ C : baz
147
+ expected: |
148
+ {"A"=>"foo", "B"=>"bar", "C"=>"baz"}
149
+ locations:
150
+ - [ "/", 1, 1 ]
151
+ - [ "/A", 1, 4 ]
152
+ - [ "/B", 2, 4 ]
153
+ - [ "/C", 3, 6 ]
154
+ ##
155
+ ---
156
+ name: mapping2
157
+ desc: nested mapping
158
+ input: |
159
+ A: 10
160
+ B:
161
+ B1:
162
+ B1-1: 21
163
+ B1-2: 22
164
+ B1-3: 23
165
+ C: 30
166
+ expected: |
167
+ {"A"=>10, "B"=>{"B1"=>{"B1-1"=>21, "B1-2"=>22, "B1-3"=>23}}, "C"=>30}
168
+ locations:
169
+ - [ "/", 1, 1 ]
170
+ - [ "/A", 1, 4 ]
171
+ - [ "/B", 3, 3 ]
172
+ - [ "/B/B1", 4, 5 ]
173
+ - [ "/B/B1/B1-1", 4, 11 ]
174
+ - [ "/B/B1/B1-2", 5, 11 ]
175
+ - [ "/B/B1/B1-3", 6, 11 ]
176
+ - [ "/C", 7, 4 ]
177
+ ##
178
+ ---
179
+ name: mapping3
180
+ desc: null item in mapping
181
+ input: |
182
+ A:
183
+ B:
184
+ B1:
185
+ B1-2:
186
+ C:
187
+ expected: |
188
+ {"A"=>nil, "B"=>{"B1"=>{"B1-2"=>nil}}, "C"=>nil}
189
+ locations:
190
+ - [ "/", 1, 1 ]
191
+ - [ "/A", 2, 1 ]
192
+ - [ "/B", 3, 3 ]
193
+ - [ "/B/B1", 4, 5 ]
194
+ - [ "/B/B1/B1-2", 5, 1 ]
195
+ - [ "/C", 6, 1 ]
196
+ ##
197
+ ---
198
+ name: mapping4
199
+ desc: mapping with empty lines
200
+ input: |
201
+
202
+ A: 1
203
+
204
+ B:
205
+
206
+
207
+ B1:
208
+
209
+
210
+
211
+ B1a: 2
212
+ C: 3
213
+
214
+ expected: |
215
+ {"A"=>1, "B"=>{"B1"=>{"B1a"=>2}}, "C"=>3}
216
+ locations:
217
+ - [ "/", 2, 1 ]
218
+ - [ "/A", 2, 4 ]
219
+ - [ "/B", 7, 3 ]
220
+ - [ "/B/B1", 11, 5 ]
221
+ - [ "/B/B1/B1a", 11, 10 ]
222
+ - [ "/C", 12, 4 ]
223
+ ##
224
+ ---
225
+ name: mapping5
226
+ desc: parse error - invalid indent of mapping.
227
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
228
+ input: |
229
+ A: 10
230
+ B: 20
231
+ B1: 21
232
+ B2: 22
233
+ C: 30
234
+ expected: |
235
+ ##
236
+ ---
237
+ name: mapping6
238
+ desc: parse error - mapping item is expected.
239
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
240
+ input: |
241
+ A:
242
+ a1: 1
243
+ a2: 2
244
+ a3 3
245
+ B:
246
+ b1: 1
247
+ b2: 2
248
+ b3 3
249
+ expected: |
250
+ locations:
251
+ ##
252
+ ---
253
+ name: combination1
254
+ desc: seq of mapping
255
+ #
256
+ input: |
257
+ -
258
+ x: 10
259
+ y: 20
260
+ -
261
+ x: 15
262
+ y: 25
263
+ #
264
+ expected: |
265
+ [{"x"=>10, "y"=>20}, {"x"=>15, "y"=>25}]
266
+ locations:
267
+ - [ "/", 1, 1 ]
268
+ - [ "/0", 2, 3 ]
269
+ - [ "/0/x", 2, 6 ]
270
+ - [ "/0/y", 3, 6 ]
271
+ - [ "/1", 5, 3 ]
272
+ - [ "/1/x", 5, 6 ]
273
+ - [ "/1/y", 6, 6 ]
274
+ ##
275
+ ---
276
+ name: combination2
277
+ desc: seq of mapping (in same line)
278
+ #
279
+ input: |
280
+ - x: 10
281
+ y: 20
282
+ - x: 15
283
+ y: 25
284
+ #
285
+ expected: |
286
+ [{"x"=>10, "y"=>20}, {"x"=>15, "y"=>25}]
287
+ locations:
288
+ - [ "/", 1, 1 ]
289
+ - [ "/0", 1, 3 ]
290
+ - [ "/0/x", 1, 6 ]
291
+ - [ "/0/y", 2, 6 ]
292
+ - [ "/1", 3, 3 ]
293
+ - [ "/1/x", 3, 6 ]
294
+ - [ "/1/y", 4, 6 ]
295
+ ##
296
+ ---
297
+ name: combination3
298
+ desc: seq of seq of seq
299
+ #
300
+ input: |
301
+ - - - a
302
+ - b
303
+ - - - c
304
+ - d
305
+ #
306
+ expected: |
307
+ [[["a", "b"]], [["c", "d"]]]
308
+ locations:
309
+ - [ "/", 1, 1 ]
310
+ - [ "/0", 1, 3 ]
311
+ - [ "/0/0", 1, 5 ]
312
+ - [ "/0/0/0", 1, 7 ]
313
+ - [ "/0/0/1", 2, 7 ]
314
+ - [ "/1", 3, 3 ]
315
+ - [ "/1/0", 3, 5 ]
316
+ - [ "/1/0/0", 3, 7 ]
317
+ - [ "/1/0/1", 4, 7 ]
318
+ ##
319
+ ---
320
+ name: combination4
321
+ desc: map of sequence
322
+ #
323
+ input: |
324
+ A:
325
+ - 1
326
+ - 2
327
+ - 3
328
+ B:
329
+ - 4
330
+ - 5
331
+ - 6
332
+ #
333
+ expected: |
334
+ {"A"=>[1, 2, 3], "B"=>[4, 5, 6]}
335
+ locations:
336
+ - [ "/", 1, 1 ]
337
+ - [ "/A", 2, 3 ]
338
+ - [ "/A/0", 2, 5 ]
339
+ - [ "/A/1", 3, 5 ]
340
+ - [ "/A/2", 4, 5 ]
341
+ - [ "/B", 6, 3 ]
342
+ - [ "/B/0", 6, 5 ]
343
+ - [ "/B/1", 7, 5 ]
344
+ - [ "/B/2", 8, 5 ]
345
+ ##
346
+ ---
347
+ name: combination5
348
+ desc: map of sequence (in same line)
349
+ #
350
+ input: |
351
+ A: - 1
352
+ - 2
353
+ - 3
354
+ B: - 4
355
+ - 5
356
+ - 6
357
+ #
358
+ expected: |
359
+ {"A"=>[1, 2, 3], "B"=>[4, 5, 6]}
360
+ locations:
361
+ - [ "/", 1, 1 ]
362
+ - [ "/A", 1, 4 ]
363
+ - [ "/A/0", 1, 6 ]
364
+ - [ "/A/1", 2, 6 ]
365
+ - [ "/A/2", 3, 6 ]
366
+ - [ "/B", 4, 4 ]
367
+ - [ "/B/0", 4, 6 ]
368
+ - [ "/B/1", 5, 6 ]
369
+ - [ "/B/2", 6, 6 ]
370
+ ##
371
+ ---
372
+ name: combination6
373
+ desc: map of map of map
374
+ #
375
+ input: |
376
+ A: a: 1: 100
377
+ 2: 200
378
+ B: b: 3: 300
379
+ "4": 400
380
+ #
381
+ expected: |
382
+ {"A"=>{"a"=>{1=>100, 2=>200}}, "B"=>{"b"=>{3=>300, "4"=>400}}}
383
+ locations:
384
+ - [ "/", 1, 1 ]
385
+ - [ "/A", 1, 4 ]
386
+ - [ "/A/a", 1, 7 ]
387
+ - [ "/A/a/1", 1, 10 ]
388
+ - [ "/A/a/2", 2, 10 ]
389
+ - [ "/B", 3, 4 ]
390
+ - [ "/B/b", 3, 7 ]
391
+ - [ "/B/b/3", 3, 10 ]
392
+ - [ "/B/b/'4'", 4, 12 ]
393
+ ##
394
+ ---
395
+ name: comment1
396
+ desc: line comment
397
+ input: |
398
+ # comment
399
+ - A
400
+ - B
401
+ # comment
402
+ -
403
+ # comment
404
+ - C
405
+ #
406
+ expected: |
407
+ ["A", "B", ["C"]]
408
+ locations:
409
+ - [ "/", 2, 1 ]
410
+ - [ "/0", 2, 3 ]
411
+ - [ "/1", 3, 3 ]
412
+ - [ "/2", 7, 3 ]
413
+ - [ "/2/0", 7, 5 ]
414
+ ##
415
+ ---
416
+ name: comment2
417
+ desc: escape line comment
418
+ #
419
+ input: |
420
+ # comment
421
+ - A
422
+ - B:
423
+ "# comment"
424
+ -
425
+ '# comment'
426
+ #
427
+ expected: |
428
+ ["A", {"B"=>"# comment"}, "# comment"]
429
+ locations:
430
+ - [ "/", 2, 1 ]
431
+ - [ "/0", 2, 3 ]
432
+ - [ "/1", 3, 3 ]
433
+ - [ "/1/B", 4, 4 ]
434
+ - [ "/2", 6, 3 ]
435
+ ##
436
+ ---
437
+ name: comment3
438
+ desc: line comment with seq and map
439
+ #
440
+ input: |
441
+ - A # comment
442
+ - B: # comment
443
+ C: foo # comment
444
+ D: "bar#bar" #comment
445
+ #
446
+ expected: |
447
+ ["A", {"B"=>{"C"=>"foo", "D"=>"bar#bar"}}]
448
+ locations:
449
+ - [ "/", 1, 1 ]
450
+ - [ "/0", 1, 3 ]
451
+ - [ "/1", 2, 3 ]
452
+ - [ "/1/B", 3, 5 ]
453
+ - [ "/1/B/C", 3, 8 ]
454
+ - [ "/1/B/D", 4, 8 ]
455
+ ##
456
+ ---
457
+ name: comment4
458
+ desc: line comment with anchor and alias
459
+ #
460
+ input: |
461
+ - &a1 # comment
462
+ foo
463
+ - *a1 # comment
464
+ #
465
+ expected: |
466
+ ["foo", "foo"]
467
+ locations:
468
+ - [ "/", 1, 1 ]
469
+ - [ "/0", 1, 3 ]
470
+ - [ "/1", 3, 3 ]
471
+ ##
472
+ ---
473
+ name: flowseq1
474
+ desc: flow style sequence
475
+ #
476
+ input: |
477
+ - [ 10, 20 ]
478
+ - [15,25,35]
479
+ #
480
+ expected: |
481
+ [[10, 20], ["15,25,35"]]
482
+ # [[10, 20], [15, 25, 35]]
483
+ locations:
484
+ - [ "/", 1, 1 ]
485
+ - [ "/0", 1, 3 ]
486
+ - [ "/0/0", 1, 5 ]
487
+ - [ "/0/1", 1, 9 ]
488
+ - [ "/1", 2, 3 ]
489
+ - [ "/1/0", 2, 4 ]
490
+ ##
491
+ ---
492
+ name: flowseq2
493
+ desc: nested flow style sequence
494
+ #
495
+ input: |
496
+ 1: [ A, [B1, B2]]
497
+ '2': [[[X]]]
498
+ 3: [[1, 1], [2, "2"], ['3', 3]]
499
+ #
500
+ expected: |
501
+ {1=>["A", ["B1", "B2"]], "2"=>[[["X"]]], 3=>[[1, 1], [2, "2"], ["3", 3]]}
502
+ #expected: |
503
+ # {1=>["A", ["B1", "B2"]],
504
+ # "2"=>[[["X"]]],
505
+ # 3=>[["x1", "y1"], ["x2", "y2"], ["x3", "y3"]]}
506
+ locations:
507
+ - [ "/", 1, 1 ]
508
+ - [ "/1", 1, 4 ]
509
+ - [ "/1/0", 1, 6 ]
510
+ - [ "/1/1", 1, 9 ]
511
+ - [ "/1/1/0", 1, 10 ]
512
+ - [ "/1/1/1", 1, 14 ]
513
+ - [ "/'2'", 2, 6 ]
514
+ - [ "/'2'/0", 2, 7 ]
515
+ - [ "/'2'/0/0", 2, 8 ]
516
+ - [ "/'2'/0/0/0", 2, 9 ]
517
+ - [ "/3", 3, 4 ]
518
+ - [ "/3/0", 3, 5 ]
519
+ - [ "/3/0/0", 3, 6 ]
520
+ - [ "/3/0/1", 3, 9 ]
521
+ - [ "/3/1", 3, 13 ]
522
+ - [ "/3/1/0", 3, 14 ]
523
+ - [ "/3/1/1", 3, 17 ]
524
+ - [ "/3/2", 3, 23 ]
525
+ - [ "/3/2/0", 3, 24 ]
526
+ - [ "/3/2/1", 3, 29 ]
527
+ ##
528
+ ---
529
+ name: flowseq3
530
+ desc: flow style sequence with some lines
531
+ #
532
+ input: |
533
+ A: [ [10, 20],
534
+ [11, 21],
535
+ [12, 22]]
536
+ B: [
537
+ [1.1,
538
+ 1.2,
539
+ 1.3
540
+ ]
541
+ ]
542
+ #
543
+ expected: |
544
+ {"A"=>[[10, 20], [11, 21], [12, 22]], "B"=>[[1.1, 1.2, 1.3]]}
545
+ locations:
546
+ - [ "/", 1, 1 ]
547
+ - [ "/A", 1, 4 ]
548
+ - [ "/A/0", 1, 6 ]
549
+ - [ "/A/0/0", 1, 7 ]
550
+ - [ "/A/0/1", 1, 11 ]
551
+ - [ "/A/1", 2, 6 ]
552
+ - [ "/A/1/0", 2, 7 ]
553
+ - [ "/A/1/1", 2, 11 ]
554
+ - [ "/A/2", 3, 6 ]
555
+ - [ "/A/2/0", 3, 7 ]
556
+ - [ "/A/2/1", 3, 11 ]
557
+ - [ "/B", 4, 4 ]
558
+ - [ "/B/0", 5, 3 ]
559
+ - [ "/B/0/0", 5, 4 ]
560
+ - [ "/B/0/1", 6, 4 ]
561
+ - [ "/B/0/2", 7, 4 ]
562
+ ##
563
+ ---
564
+ name: flowseq4
565
+ desc: invalid flow style seq (sequence item required (or last comma is extra).)
566
+ mesg: sequence item required (or last comma is extra).
567
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
568
+ #
569
+ input: |
570
+ A: [ [10,20], ]
571
+ #
572
+ expected: |
573
+ locations:
574
+ ##
575
+ ---
576
+ name: flowseq5
577
+ desc: invalid flow style seq (flow style sequence requires ']').
578
+ mesg: flow style sequence requires ']'
579
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
580
+ #
581
+ input: |
582
+ A: [ [10,20]
583
+ B: [ [30, 40]]
584
+ #
585
+ expected: |
586
+ locations:
587
+ ##
588
+ ---
589
+ name: flowseq6
590
+ desc: invalid flow style seq (flow style sequence requires ']').
591
+ mesg: flow style sequence is closed but got ']'.
592
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
593
+ #
594
+ input: |
595
+ [ 10 ]]
596
+ #
597
+ expected: |
598
+ locations:
599
+ ##
600
+ ---
601
+ name: flowmap1
602
+ desc: flow style map
603
+ #
604
+ input: |
605
+ - { A1: 10, A2: 20 }
606
+ - {B1: 15, 'B2': 25, "B3": 35}
607
+ #
608
+ expected: |
609
+ [{"A1"=>10, "A2"=>20}, {"B1"=>15, "B2"=>25, "B3"=>35}]
610
+ locations:
611
+ - [ "/", 1, 1 ]
612
+ - [ "/0", 1, 3 ]
613
+ - [ "/0/A1", 1, 9 ]
614
+ - [ "/0/A2", 1, 17 ]
615
+ - [ "/1", 2, 3 ]
616
+ - [ "/1/B1", 2, 8 ]
617
+ - [ "/1/B2", 2, 18 ]
618
+ - [ "/1/B3", 2, 28 ]
619
+ ##
620
+ ---
621
+ name: flowmap2
622
+ desc: flow style map nested
623
+ #
624
+ input: |
625
+ A: { x: {y: {z: 10}}}
626
+ B: { a: 1, b: {c: 2, d: 3, e: {f: 4}}, g: 5}
627
+ #
628
+ expected: |
629
+ {"A"=>{"x"=>{"y"=>{"z"=>10}}}, "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
630
+ #expected: |
631
+ # {"A"=>{"x"=>{"y"=>{"z"=>10}}},
632
+ # "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
633
+ locations:
634
+ - [ "/", 1, 1 ]
635
+ - [ "/A", 1, 4 ]
636
+ - [ "/A/x", 1, 9 ]
637
+ - [ "/A/x/y", 1, 13 ]
638
+ - [ "/A/x/y/z", 1, 17 ]
639
+ - [ "/B", 2, 4 ]
640
+ - [ "/B/a", 2, 9 ]
641
+ - [ "/B/b", 2, 15 ]
642
+ - [ "/B/b/c", 2, 19 ]
643
+ - [ "/B/b/d", 2, 25 ]
644
+ - [ "/B/b/e", 2, 31 ]
645
+ - [ "/B/b/e/f", 2, 35 ]
646
+ - [ "/B/g", 2, 43 ]
647
+ ##
648
+ ---
649
+ name: flowmap3
650
+ desc: flow style map with some lines
651
+ #
652
+ input: |
653
+ A: { x:
654
+ {y:
655
+ {z: 10}
656
+ }
657
+ }
658
+ B: {
659
+ a: 1,
660
+ b: {
661
+ c: 2,
662
+ d: 3,
663
+ e: {
664
+ f: 4
665
+ }
666
+ },
667
+ g: 5
668
+ }
669
+ #
670
+ expected: |
671
+ {"A"=>{"x"=>{"y"=>{"z"=>10}}}, "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
672
+ #expected: |
673
+ # {"A"=>{"x"=>{"y"=>{"z"=>10}}},
674
+ # "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
675
+ locations:
676
+ - [ "/", 1, 1 ]
677
+ - [ "/A", 1, 4 ]
678
+ - [ "/A/x", 2, 6 ]
679
+ - [ "/A/x/y", 3, 8 ]
680
+ - [ "/A/x/y/z", 3, 12 ]
681
+ - [ "/B", 6, 4 ]
682
+ - [ "/B/a", 7, 6 ]
683
+ - [ "/B/b", 8, 6 ]
684
+ - [ "/B/b/c", 9, 8 ]
685
+ - [ "/B/b/d", 10, 8 ]
686
+ - [ "/B/b/e", 11, 8 ]
687
+ - [ "/B/b/e/f", 12, 10 ]
688
+ - [ "/B/g", 15, 6 ]
689
+ ##
690
+ ---
691
+ name: flowmap4
692
+ desc: invalid flow style map (mapping item required (or last comma is extra).)
693
+ mesg: mapping item required (or last comma is extra).
694
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
695
+ #
696
+ input: |
697
+ - {A: 10, B: 20, }
698
+ #
699
+ expected: |
700
+ locations:
701
+ ##
702
+ ---
703
+ name: flowmap5
704
+ desc: invalid flow style map (flow style mapping requires '}').
705
+ mesg: flow style mapping requires '}'
706
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
707
+ #
708
+ input: |
709
+ - {A: { x: 10, y: 20 }
710
+ - {A: { x: 11, y: 21 }}
711
+ #
712
+ expected: |
713
+ locations:
714
+ ##
715
+ ---
716
+ name: flowmap6
717
+ desc: invalid flow style map (flow style mapping requires ']').
718
+ mesg: flow style mapping is closed but got '}'.
719
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
720
+ #
721
+ input: |
722
+ { x: 10 }}
723
+ #
724
+ expected: |
725
+ locations:
726
+ ##
727
+ ---
728
+ name: flowscalar1
729
+ desc: string containing backslash escape
730
+ #
731
+ input: |
732
+ [ {"key1": "\"\\\n"},
733
+ {'key2': '\'\\\n'} ]
734
+ #
735
+ expected: |
736
+ [{"key1"=>"\"\\\n"}, {"key2"=>"'\\\\n"}]
737
+ locations:
738
+ - [ "/", 1, 1 ]
739
+ - [ "/0", 1, 3 ]
740
+ - [ "/0/key1", 1, 12 ]
741
+ - [ "/1", 2, 3 ]
742
+ - [ "/1/key2", 2, 12 ]
743
+ ##
744
+ ---
745
+ name: flowcombination1
746
+ desc: combination of flow style seq and map
747
+ #
748
+ input: |
749
+ [
750
+ {name: ' foo ',
751
+ e-mail: foo@mail.com},
752
+ {name: ba z,
753
+ e-mail: ba__z@mail.com }
754
+ ]
755
+ #
756
+ expected: |
757
+ [{"e-mail"=>"foo@mail.com", "name"=>" foo "}, {"e-mail"=>"ba__z@mail.com", "name"=>"ba z"}]
758
+ locations:
759
+ - [ "/", 1, 1 ]
760
+ - [ "/0", 2, 3 ]
761
+ - [ "/0/name", 2, 10 ]
762
+ - [ "/0/e-mail", 3, 12 ]
763
+ - [ "/1", 4, 3 ]
764
+ - [ "/1/name", 4, 10 ]
765
+ - [ "/1/e-mail", 5, 12 ]
766
+ ##
767
+ ---
768
+ name: blocktext01
769
+ desc: parse_blocktext
770
+ #
771
+ input: |
772
+ - text1: |
773
+ foo
774
+ bar
775
+ baz
776
+ - text2: |
777
+ aaa
778
+ bbb
779
+ ccc
780
+ - |
781
+ foo
782
+ bar
783
+ baz
784
+ - |
785
+ aaa
786
+ bbb
787
+ ccc
788
+ #
789
+ expected: |
790
+ [{"text1"=>"foo\nbar\nbaz\n"}, {"text2"=>"aaa\n bbb\n ccc\n"}, "foo\nbar\nbaz\n", "aaa\n bbb\n ccc\n"]
791
+ locations:
792
+ - [ "/", 1, 1 ]
793
+ - [ "/0", 1, 3 ]
794
+ - [ "/0/text1", 1, 10 ]
795
+ - [ "/1", 5, 3 ]
796
+ - [ "/1/text2", 5, 10 ]
797
+ - [ "/2", 9, 3 ]
798
+ - [ "/3", 13, 3 ]
799
+ ##
800
+ ---
801
+ name: blocktext02
802
+ desc: block text with '|+' or '|-'
803
+ #
804
+ input: |
805
+ - text1: |
806
+ A
807
+
808
+ B
809
+ C
810
+
811
+
812
+ - text2: |+
813
+ A
814
+
815
+ B
816
+ C
817
+
818
+
819
+ - text3: |-
820
+ A
821
+
822
+ B
823
+ C
824
+
825
+
826
+ #
827
+ expected: |
828
+ [{"text1"=>"A\n\nB\nC\n"}, {"text2"=>"A\n\nB\nC\n\n\n"}, {"text3"=>"A\n\nB\nC"}]
829
+ locations:
830
+ - [ "/", 1, 1 ]
831
+ - [ "/0", 1, 3 ]
832
+ - [ "/0/text1", 1, 10 ]
833
+ - [ "/1", 8, 3 ]
834
+ - [ "/1/text2", 8, 10 ]
835
+ - [ "/2", 15, 3 ]
836
+ - [ "/2/text3", 15, 10 ]
837
+ ##
838
+ ---
839
+ name: blocktext03
840
+ desc: block text with '|n'
841
+ #
842
+ input: |
843
+ - text1: |3
844
+ A
845
+
846
+ B
847
+ C
848
+
849
+
850
+ - text2: |+3
851
+ A
852
+
853
+ B
854
+ C
855
+
856
+
857
+ - text3: |-3
858
+ A
859
+
860
+ B
861
+ C
862
+
863
+
864
+ #
865
+ expected: |
866
+ [{"text1"=>" A\n\n B\n C\n"}, {"text2"=>" A\n\n B\n C\n\n\n"}, {"text3"=>" A\n\n B\n C"}]
867
+ locations:
868
+ - [ "/", 1, 1 ]
869
+ - [ "/0", 1, 3 ]
870
+ - [ "/0/text1", 1, 10 ]
871
+ - [ "/1", 8, 3 ]
872
+ - [ "/1/text2", 8, 10 ]
873
+ - [ "/2", 15, 3 ]
874
+ - [ "/2/text3", 15, 10 ]
875
+ ##
876
+ #---
877
+ #name: blocktext04
878
+ #desc: block text with '| foo'
879
+ ##
880
+ #input: |
881
+ # - text1: | foo
882
+ # A
883
+ #
884
+ # B
885
+ # C
886
+ #
887
+ # - | foo
888
+ # A
889
+ # B
890
+ # C
891
+ ##
892
+ #expected: |
893
+ # [{"text1"=>"foo A\n\nB\nC\n"}, "fooA\n B\n C\n"]
894
+ ###
895
+ ---
896
+ name: blocktext05
897
+ desc: block text with '#' (comment)
898
+ #
899
+ input: |
900
+ #
901
+ - text1: |
902
+ A
903
+ #
904
+ B
905
+ #
906
+ text2: |
907
+ #
908
+ #
909
+ #
910
+ - |
911
+ A
912
+ #
913
+ B
914
+ #
915
+ - |
916
+ #
917
+ #
918
+ #
919
+ - x
920
+
921
+ #
922
+ expected: |
923
+ [{"text1"=>"A\n#\nB\n", "text2"=>"#\n#\n"}, "A\n#\nB\n", "#\n#\n", "x"]
924
+ locations:
925
+ - [ "/", 2, 3 ]
926
+ - [ "/0", 2, 5 ]
927
+ - [ "/0/text1", 2, 12 ]
928
+ - [ "/0/text2", 7, 12 ]
929
+ - [ "/1", 11, 5 ]
930
+ - [ "/2", 16, 5 ]
931
+ - [ "/3", 20, 5 ]
932
+ ##
933
+ ---
934
+ name: blocktext06
935
+ desc: invalid block text
936
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
937
+ #
938
+ input: |
939
+ - |
940
+ a
941
+ b
942
+ c
943
+ #
944
+ expected: |
945
+ ##
946
+ ---
947
+ name: blocktext11
948
+ desc: parse_blocktext (>)
949
+ #
950
+ input: |
951
+ - text1: >
952
+ foo
953
+ bar
954
+ baz
955
+ - text2: >
956
+ aaa
957
+ bbb
958
+ ccc
959
+ - >
960
+ foo
961
+ bar
962
+ baz
963
+ - >
964
+ aaa
965
+ bbb
966
+ ccc
967
+ #
968
+ expected: |
969
+ [{"text1"=>"foo bar baz\n"}, {"text2"=>"aaa\n bbb\n ccc\n"}, "foo bar baz\n", "aaa\n bbb\n ccc\n"]
970
+ # [{"text1"=>"foo bar baz\n"}, {"text2"=>"aaa bbb ccc\n"}, "foo bar baz\n", "aaa bbb ccc\n"]
971
+ locations:
972
+ - [ "/", 1, 1 ]
973
+ - [ "/0", 1, 3 ]
974
+ - [ "/0/text1", 1, 10 ]
975
+ - [ "/1", 5, 3 ]
976
+ - [ "/1/text2", 5, 10 ]
977
+ - [ "/2", 9, 3 ]
978
+ - [ "/3", 13, 3 ]
979
+ ##
980
+ ---
981
+ name: blocktext12
982
+ desc: block text with '>+' or '>-'
983
+ #
984
+ input: |
985
+ - text1: >
986
+ A
987
+
988
+ B
989
+ C
990
+
991
+
992
+ - text2: >+
993
+ A
994
+
995
+ B
996
+ C
997
+
998
+
999
+ - text3: >-
1000
+ A
1001
+
1002
+ B
1003
+ C
1004
+
1005
+
1006
+ #
1007
+ expected: |
1008
+ [{"text1"=>"A\nB C\n"}, {"text2"=>"A\nB C\n\n\n"}, {"text3"=>"A\nB C"}]
1009
+ locations:
1010
+ - [ "/", 1, 1 ]
1011
+ - [ "/0", 1, 3 ]
1012
+ - [ "/0/text1", 1, 10 ]
1013
+ - [ "/1", 8, 3 ]
1014
+ - [ "/1/text2", 8, 10 ]
1015
+ - [ "/2", 15, 3 ]
1016
+ - [ "/2/text3", 15, 10 ]
1017
+ ##
1018
+ ---
1019
+ name: blocktext13
1020
+ desc: block text with '>n'
1021
+ #
1022
+ input: |
1023
+ - >2
1024
+ A
1025
+
1026
+ B
1027
+ C
1028
+
1029
+
1030
+ - >+2
1031
+ A
1032
+
1033
+ B
1034
+ C
1035
+
1036
+
1037
+ - >-2
1038
+ A
1039
+
1040
+ B
1041
+ C
1042
+
1043
+
1044
+ #
1045
+ expected: |
1046
+ [" A\n\n B\n C\n", " A\n\n B\n C\n\n\n", " A\n\n B\n C"]
1047
+ # [" A\n B C\n", " A\n B C\n\n\n", " A\n B C"]
1048
+ locations:
1049
+ - [ "/", 1, 1 ]
1050
+ - [ "/0", 1, 3 ]
1051
+ - [ "/1", 8, 3 ]
1052
+ - [ "/2", 15, 3 ]
1053
+ ##
1054
+ #---
1055
+ #name: blocktext14
1056
+ #desc: block text with '> foo'
1057
+ ##
1058
+ #input: |
1059
+ # - text1: > foo
1060
+ # A
1061
+ #
1062
+ # B
1063
+ # C
1064
+ #
1065
+ # - > foo
1066
+ # A
1067
+ # B
1068
+ # C
1069
+ ##
1070
+ #expected: |
1071
+ # [{"text1"=>"foo A\nB C\n"}, "fooA B C\n"]
1072
+ ###
1073
+ ---
1074
+ name: blocktext15
1075
+ desc: block text with '#' (comment)
1076
+ #
1077
+ input: |
1078
+ #
1079
+ - text1: >
1080
+ AA
1081
+ ##
1082
+ BB
1083
+ #
1084
+ text2: >
1085
+ #
1086
+ #
1087
+ #
1088
+ - >
1089
+ AA
1090
+ ##
1091
+ BB
1092
+ #
1093
+ - >
1094
+ #
1095
+ #
1096
+ #
1097
+ - x
1098
+
1099
+ #
1100
+ expected: |
1101
+ [{"text1"=>"AA ## BB\n", "text2"=>"# #\n"}, "AA ## BB\n", "# #\n", "x"]
1102
+ locations:
1103
+ - [ "/", 2, 3 ]
1104
+ - [ "/0", 2, 5 ]
1105
+ - [ "/0/text1", 2, 12 ]
1106
+ - [ "/0/text2", 7, 12 ]
1107
+ - [ "/1", 11, 5 ]
1108
+ - [ "/2", 16, 5 ]
1109
+ - [ "/3", 20, 5 ]
1110
+ ##
1111
+ ---
1112
+ name: blocktext16
1113
+ desc: invalid block text
1114
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
1115
+ #
1116
+ input: |
1117
+ - >
1118
+ a
1119
+ b
1120
+ c
1121
+ #
1122
+ expected: |
1123
+ ##
1124
+ ---
1125
+ name: anchor1
1126
+ desc: parse_anchor, parse_alias
1127
+ #
1128
+ input: |
1129
+ - &a1 foo
1130
+ - &a2
1131
+ bar
1132
+ - *a1
1133
+ - *a2
1134
+ #
1135
+ expected: |
1136
+ ["foo", "bar", "foo", "bar"]
1137
+ locations:
1138
+ - [ "/", 1, 1 ]
1139
+ - [ "/0", 1, 3 ]
1140
+ - [ "/1", 2, 3 ]
1141
+ - [ "/2", 4, 3 ]
1142
+ - [ "/3", 5, 3 ]
1143
+ ##
1144
+ ---
1145
+ name: anchor2
1146
+ desc: parse_anchor, parse_alias
1147
+ #
1148
+ input: |
1149
+ - A: &a1
1150
+ x: 10
1151
+ y: 20
1152
+ - B: bar
1153
+ - C: *a1
1154
+ #
1155
+ expected: |
1156
+ [{"A"=>{"x"=>10, "y"=>20}}, {"B"=>"bar"}, {"C"=>{"x"=>10, "y"=>20}}]
1157
+ locations:
1158
+ - [ "/", 1, 1 ]
1159
+ - [ "/0", 1, 3 ]
1160
+ - [ "/0/A", 1, 6 ]
1161
+ - [ "/0/A/x", 2, 7 ]
1162
+ - [ "/0/A/y", 3, 7 ]
1163
+ - [ "/1", 4, 3 ]
1164
+ - [ "/1/B", 4, 6 ]
1165
+ - [ "/2", 5, 3 ]
1166
+ - [ "/2/C", 5, 6 ]
1167
+ ##
1168
+ ---
1169
+ name: anchor3
1170
+ desc: anchor on child node
1171
+ testopts: { recursive: yes }
1172
+ #
1173
+ input: |
1174
+ - A: &a1
1175
+ x: 10
1176
+ y: 20
1177
+ z: *a1
1178
+ #
1179
+ expected: |
1180
+ [{"A"=>{"x"=>10, "y"=>20, "z"=>{...}}}]
1181
+ locations:
1182
+ - [ "/", 1, 1 ]
1183
+ - [ "/0", 1, 3 ]
1184
+ - [ "/0/A", 1, 6 ]
1185
+ - [ "/0/A/x", 2, 7 ]
1186
+ - [ "/0/A/y", 3, 7 ]
1187
+ - [ "/0/A/z", 4, 7 ]
1188
+ ##
1189
+ ---
1190
+ name: anchor4
1191
+ desc: preceding anchor
1192
+ #
1193
+ input: |
1194
+ - *a1
1195
+ - *a1
1196
+ - foo
1197
+ - &a1 bar
1198
+ #
1199
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
1200
+ errormsg: anchor 'a1' not found.
1201
+ expected: |
1202
+ ["bar", "bar", "foo", "bar"]
1203
+ locations:
1204
+ - [ "/", 1, 1 ]
1205
+ - [ "/0", 1, 3 ]
1206
+ - [ "/1", 2, 3 ]
1207
+ - [ "/2", 3, 3 ]
1208
+ - [ "/3", 4, 3 ]
1209
+ ##
1210
+ ---
1211
+ name: anchor5
1212
+ desc: anchor not found
1213
+ exception*: { ruby: Kwalify::SyntaxError, java: kwalify.SyntaxException }
1214
+ mesg: anchor 'a2' not found (Kwalify::SyntaxError)
1215
+ #
1216
+ input: |
1217
+ - &a1 foo
1218
+ - bar
1219
+ - *a2
1220
+ #
1221
+ expected: |
1222
+ locations:
1223
+ ##
1224
+ ---
1225
+ name: anchor6
1226
+ desc: anchor on child node
1227
+ testopts: { recursive: yes }
1228
+ #
1229
+ input: |
1230
+ type: seq
1231
+ sequence:
1232
+ - &employee
1233
+ type: map
1234
+ mapping:
1235
+ name:
1236
+ type: str
1237
+ post:
1238
+ type: str
1239
+ enum:
1240
+ - exective
1241
+ - manager
1242
+ - clerk
1243
+ supervisor: *employee
1244
+ #
1245
+ expected*:
1246
+ ruby: |
1247
+ {"sequence"=>
1248
+ [{"type"=>"map",
1249
+ "mapping"=>
1250
+ {"name"=>{"type"=>"str"},
1251
+ "post"=>{"type"=>"str", "enum"=>["exective", "manager", "clerk"]},
1252
+ "supervisor"=>{...}}}],
1253
+ "type"=>"seq"}
1254
+ java: |
1255
+ {"sequence"=>[{"mapping"=>{"name"=>{"type"=>"str"}, "post"=>{"enum"=>["exective", "manager", "clerk"], "type"=>"str"}, "supervisor"=>{...}}, "type"=>"map"}], "type"=>"seq"}
1256
+ locations:
1257
+ - [ "/", 1, 1 ]
1258
+ - [ "/type", 1, 14 ]
1259
+ - [ "/sequence", 3, 3 ]
1260
+ - [ "/sequence/0", 3, 5 ]
1261
+ - [ "/sequence/0/type", 4, 14 ]
1262
+ - [ "/sequence/0/mapping", 6, 7 ]
1263
+ - [ "/sequence/0/mapping/name", 7, 9 ]
1264
+ - [ "/sequence/0/mapping/name/type", 7, 17 ]
1265
+ - [ "/sequence/0/mapping/post", 9, 9 ]
1266
+ - [ "/sequence/0/mapping/post/type", 9, 17 ]
1267
+ - [ "/sequence/0/mapping/post/enum", 11, 11 ]
1268
+ - [ "/sequence/0/mapping/post/enum/0", 11, 13 ]
1269
+ - [ "/sequence/0/mapping/post/enum/1", 12, 13 ]
1270
+ - [ "/sequence/0/mapping/post/enum/2", 13, 13 ]
1271
+ - [ "/sequence/0/mapping/supervisor", 14, 19 ]
1272
+ ##
1273
+ ---
1274
+ name: anchor7
1275
+ desc: anchor and alias with flow style data
1276
+ #
1277
+ input: |
1278
+ - &a1 {v: &a2 [1, 2, 3]}
1279
+ - [x, *a1, y]
1280
+ - {z: *a2}
1281
+ #
1282
+ expected*:
1283
+ ruby: |
1284
+ [{"v"=>[1, 2, 3]}, ["x", {"v"=>[1, 2, 3]}, "y"], {"z"=>[1, 2, 3]}]
1285
+ java: |
1286
+ [{"v"=>[1, 2, 3]}, ["x", {"v"=>[1, 2, 3]}, "y"], {"z"=>[1, 2, 3]}]
1287
+ ##
1288
+ ---
1289
+ name: anchor8
1290
+ desc: recursive alias with flow style data
1291
+ testopts: { recursive: yes }
1292
+ #
1293
+ input: |
1294
+ - &a1
1295
+ {v: &a2 [*a1, *a2]}
1296
+ #
1297
+ expected*:
1298
+ ruby: |
1299
+ [{"v"=>[{...}, [...]]}]
1300
+ java: |
1301
+ [{"v"=>[{...}, [...]]}]
1302
+ ##
1303
+ ---
1304
+ name: preceding1
1305
+ desc: preceding anchor
1306
+ testopts: { preceding_alias: yes }
1307
+ #
1308
+ input: |
1309
+ - *a1
1310
+ - &a1 AAA
1311
+ #
1312
+ expected*:
1313
+ ruby: |
1314
+ ["AAA", "AAA"]
1315
+ java: |
1316
+ ["AAA", "AAA"]
1317
+ locations:
1318
+ - [ "/", 1, 1 ]
1319
+ - [ "/0", 1, 3 ]
1320
+ - [ "/1", 2, 3 ]
1321
+ ##
1322
+ ---
1323
+ name: preceding2
1324
+ desc: preceding anchor
1325
+ testopts: { preceding_alias: yes, pp: yes }
1326
+ #
1327
+ input: |
1328
+ groups:
1329
+ - name: wheel
1330
+ owner: *ROOT
1331
+ - name: users
1332
+ owner: *USER1
1333
+
1334
+ users:
1335
+ - &ROOT
1336
+ name: root
1337
+ email: root@localhost
1338
+ - &USER1
1339
+ name: user1
1340
+ email: user1@localhost
1341
+ #
1342
+ expected*:
1343
+ ruby: |
1344
+ {"groups"=>
1345
+ [{"name"=>"wheel", "owner"=>{"name"=>"root", "email"=>"root@localhost"}},
1346
+ {"name"=>"users", "owner"=>{"name"=>"user1", "email"=>"user1@localhost"}}],
1347
+ "users"=>
1348
+ [{"name"=>"root", "email"=>"root@localhost"},
1349
+ {"name"=>"user1", "email"=>"user1@localhost"}]}
1350
+ java: |
1351
+ locations:
1352
+ - [ "/", 1, 1 ]
1353
+ - [ "/groups", 2, 3 ]
1354
+ - [ "/groups/0", 2, 5 ]
1355
+ - [ "/groups/0/name", 2, 12 ]
1356
+ - [ "/groups/0/owner", 3, 12 ]
1357
+ - [ "/groups/1", 4, 5 ]
1358
+ - [ "/groups/1/name", 4, 12 ]
1359
+ - [ "/groups/1/owner", 5, 12 ]
1360
+ - [ "/users", 8, 3 ]
1361
+ - [ "/users/0", 8, 5 ]
1362
+ - [ "/users/0/name", 9, 11 ]
1363
+ - [ "/users/0/email", 10, 12 ]
1364
+ - [ "/users/1", 11, 5 ]
1365
+ - [ "/users/1/name", 12, 11 ]
1366
+ - [ "/users/1/email", 13, 12 ]
1367
+ ##
1368
+ ---
1369
+ name: preceding3
1370
+ desc: preceding anchor not found
1371
+ testopts: { preceding_alias: yes }
1372
+ #
1373
+ input: |
1374
+ groups:
1375
+ - name: wheel
1376
+ owner: *ROOT
1377
+ - name: users
1378
+ owner: *USER1
1379
+
1380
+ users:
1381
+ - &ROOT
1382
+ name: root
1383
+ email: root@localhost
1384
+ - &USER2
1385
+ name: user1
1386
+ email: user1@localhost
1387
+ #
1388
+ exception*:
1389
+ ruby: Kwalify::SyntaxError
1390
+ #java: kwalify.SyntaxError
1391
+ errormsg*:
1392
+ ruby: "*USER1: anchor not found."
1393
+ #java: "*USER1: anchor not found."
1394
+ location: { linenum: 5, column: 13 }
1395
+ locations:
1396
+ ##
1397
+ ---
1398
+ name: tag1
1399
+ desc: tag
1400
+ #
1401
+ input: |
1402
+ - !str 123
1403
+ - foo: !text 123
1404
+ #
1405
+ expected: |
1406
+ [123, {"foo"=>123}]
1407
+ locations:
1408
+ - [ "/", 1, 1 ]
1409
+ - [ "/0", 1, 3 ]
1410
+ - [ "/1", 2, 3 ]
1411
+ - [ "/1/foo", 2, 8 ]
1412
+ ##
1413
+ ---
1414
+ name: docend1
1415
+ desc: ... (document end)
1416
+ #
1417
+ input: |
1418
+ - aaa
1419
+ - bbb
1420
+ ...
1421
+ - ccc
1422
+ #
1423
+ expected: |
1424
+ ["aaa", "bbb"]
1425
+ locations:
1426
+ - [ "/", 1, 1 ]
1427
+ - [ "/0", 1, 3 ]
1428
+ - [ "/1", 2, 3 ]
1429
+ - [ "/2", null, null ]
1430
+ ##
1431
+ #---
1432
+ name: docend2
1433
+ desc: ... (document end) in block text
1434
+ #
1435
+ input: |
1436
+ - |
1437
+ foo
1438
+ ...
1439
+ bar
1440
+ #
1441
+ expected: |
1442
+ ["foo\n...\nbar\n"]
1443
+ locations:
1444
+ - [ "/", 1, 1 ]
1445
+ - [ "/0", 1, 3 ]
1446
+ ##
1447
+ ---
1448
+ name: docstart1
1449
+ desc: --- (document start)
1450
+ #
1451
+ input: |
1452
+ # comment
1453
+ ---
1454
+ - foo
1455
+ - bar
1456
+ #
1457
+ expected: |
1458
+ ["foo", "bar"]
1459
+ locations:
1460
+ - [ "/", 3, 1 ]
1461
+ - [ "/0", 3, 3 ]
1462
+ - [ "/1", 4, 3 ]
1463
+ ##
1464
+ ---
1465
+ name: docstart2
1466
+ desc: --- (document start) with tag
1467
+ #
1468
+ input: |
1469
+ # comment
1470
+ --- %YAML !seq
1471
+ - foo
1472
+ - bar
1473
+ #
1474
+ expected: |
1475
+ ["foo", "bar"]
1476
+ locations:
1477
+ - [ "/", 3, 1 ]
1478
+ - [ "/0", 3, 3 ]
1479
+ - [ "/1", 4, 3 ]
1480
+ ##
1481
+ ---
1482
+ name: docstart3
1483
+ desc: --- (document start) with tag
1484
+ #
1485
+ input: |
1486
+ - |
1487
+ foo
1488
+ ---
1489
+ bar
1490
+ ---
1491
+ baz
1492
+ #
1493
+ expected: |
1494
+ ["foo\n---\nbar\n---\nbaz\n"]
1495
+ locations:
1496
+ - [ "/", 1, 1 ]
1497
+ - [ "/0", 1, 3 ]
1498
+ ##
1499
+ ---
1500
+ name: default1
1501
+ desc: map default value
1502
+ #
1503
+ input: |
1504
+ - A: 10
1505
+ B: 20
1506
+ =: -1
1507
+ - K:
1508
+ x: 10
1509
+ y: 20
1510
+ =:
1511
+ x: 0
1512
+ y: 0
1513
+ #
1514
+ expected: |
1515
+ [{"A"=>10, "B"=>20}, {"K"=>{"x"=>10, "y"=>20}}]
1516
+ locations:
1517
+ - [ "/", 1, 1 ]
1518
+ - [ "/0", 1, 3 ]
1519
+ - [ "/0/A", 1, 6 ]
1520
+ - [ "/0/B", 2, 6 ]
1521
+ - [ "/1", 4, 3 ]
1522
+ - [ "/1/K", 5, 5 ]
1523
+ - [ "/1/K/x", 5, 8 ]
1524
+ - [ "/1/K/y", 6, 8 ]
1525
+ ##
1526
+ ---
1527
+ name: merge1
1528
+ desc: merge key '<<'
1529
+ #
1530
+ input: |
1531
+ - &a1
1532
+ A: 10
1533
+ B: 20
1534
+ - C: 30
1535
+ <<: *a1
1536
+ A: ~
1537
+ #
1538
+ expected: |
1539
+ [{"A"=>10, "B"=>20}, {"A"=>nil, "B"=>20, "C"=>30}]
1540
+ locations:
1541
+ - [ "/", 1, 1 ]
1542
+ - [ "/0", 1, 3 ]
1543
+ - [ "/0/A", 2, 6 ]
1544
+ - [ "/0/B", 3, 6 ]
1545
+ - [ "/1", 4, 3 ]
1546
+ - [ "/1/C", 4, 6 ]
1547
+ - [ "/1/A", 6, 6 ]
1548
+ ##
1549
+ ---
1550
+ name: scalar1
1551
+ desc: scalar with sequence
1552
+ input: |
1553
+ - abc
1554
+ - 123
1555
+ - 3.14
1556
+ - true
1557
+ - false
1558
+ - yes
1559
+ - no
1560
+ - ~
1561
+ - null
1562
+ - "123"
1563
+ - '456'
1564
+ - 2005-01-01
1565
+ - :sym
1566
+ expected*:
1567
+ ruby: |
1568
+ ["abc", 123, 3.14, true, false, true, false, nil, nil, "123", "456", #<Date: 4906743/2,0,2299161>, :sym]
1569
+ # ruby: |
1570
+ # ["abc",
1571
+ # 123,
1572
+ # 3.14,
1573
+ # true,
1574
+ # false,
1575
+ # true,
1576
+ # false,
1577
+ # nil,
1578
+ # nil,
1579
+ # "123",
1580
+ # "456",
1581
+ # #<Date: 4906743/2,0,2299161>,
1582
+ # :sym]
1583
+ java: |
1584
+ ["abc", 123, 3.14, true, false, true, false, nil, nil, "123", "456", Tue Feb 01 00:00:00 JST 2005, ":sym"]
1585
+ # ["abc", 123, true, false, true, false, nil, nil, "123", "456", #<Date: 4906743/2,0,2299161>, :sym]
1586
+ ##
1587
+ ---
1588
+ name: scalar2
1589
+ desc: mapping of scalar
1590
+ testopts: { pp: yes }
1591
+ input: |
1592
+ - abc : ABC
1593
+ - 123 : 123
1594
+ - 3.14 : 3.14
1595
+ - true : true
1596
+ - false : false
1597
+ - yes : yes
1598
+ - no : no
1599
+ - null : ~
1600
+ - null : null
1601
+ - "123" : "123"
1602
+ - '456' : '456'
1603
+ - 2005-01-01 : 2005-01-01
1604
+ - :sym : :sym
1605
+ # - ~ : ~
1606
+ # - 2005-01-01 00:00:00 : 2005-01-01 00:00:00
1607
+ expected*:
1608
+ ruby: |
1609
+ [{"abc"=>"ABC"},
1610
+ {123=>123},
1611
+ {3.14=>3.14},
1612
+ {true=>true},
1613
+ {false=>false},
1614
+ {true=>true},
1615
+ {false=>false},
1616
+ {nil=>nil},
1617
+ {nil=>nil},
1618
+ {"123"=>"123"},
1619
+ {"456"=>"456"},
1620
+ {#<Date: 4906743/2,0,2299161>=>#<Date: 4906743/2,0,2299161>},
1621
+ {:sym=>:sym}]
1622
+ java: |
1623
+ [{"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"}]
1624
+ # {123=>1.23, 3.14=>314, "abc"=>"ABC"}
1625
+ # {"abc"=>"ABC", 3.14=>314, 123=>1.23}
1626
+ locations:
1627
+ - [ "/", 1, 1 ]
1628
+ - [ "/0/abc", 1, 9 ]
1629
+ - [ "/1/123", 2, 9 ]
1630
+ - [ "/2/3.14", 3, 10 ]
1631
+ - [ "/3/true", 4, 10 ]
1632
+ - [ "/4/false", 5, 11 ]
1633
+ - [ "/5/yes", 6, 9 ]
1634
+ - [ "/6/no", 7, 8 ]
1635
+ - [ "/7/null", 8, 10 ]
1636
+ - [ "/8/null", 9, 10 ]
1637
+ - [ '/9/"123"/', 10, 11 ]
1638
+ - [ "/10/'456'/", 11, 11 ]
1639
+ - [ "/11/2005-01-01", 12, 16 ]
1640
+ - [ "/12/:sym", 13, 10 ]
1641
+ ##
1642
+ ---
1643
+ name: str1
1644
+ desc: single/double quoted
1645
+ input: |
1646
+ -
1647
+ - 'a'
1648
+ - "b"
1649
+ - 'A': 'a'
1650
+ "B": 'b'
1651
+ - ['C', "c"]
1652
+ - {"D": "d"}
1653
+ expected: |
1654
+ [["a", "b"], {"A"=>"a", "B"=>"b"}, ["C", "c"], {"D"=>"d"}]
1655
+ locations:
1656
+ - [ "/", 1, 1 ]
1657
+ - [ "/0", 2, 2 ]
1658
+ - [ "/0/0", 2, 4 ]
1659
+ - [ "/0/1", 3, 4 ]
1660
+ - [ "/1", 4, 3 ]
1661
+ - [ "/1/A", 4, 8 ]
1662
+ - [ "/1/B", 5, 8 ]
1663
+ - [ "/2", 6, 3 ]
1664
+ - [ "/2/0", 6, 4 ]
1665
+ - [ "/2/1", 6, 9 ]
1666
+ - [ "/3", 7, 3 ]
1667
+ - [ "/3/D", 7, 9 ]
1668
+ ##
1669
+ ---
1670
+ name: str2
1671
+ desc: escape sequence
1672
+ input: |
1673
+ -
1674
+ - '\\\'\t\b\r\n'
1675
+ - "\\\"\t\b\r\n"
1676
+ - 'A': '\\\'\t\b\r\n'
1677
+ "B": "\\\"\t\b\r\n"
1678
+ - ['\\\'\t\b\r\n', "\\\"\t\b\r\n"]
1679
+ - {'A': '\\\'\t\b\r\n',
1680
+ "B": "\\\"\t\b\r\n"}
1681
+ expected: |
1682
+ [["\\'\\t\\b\\r\\n", "\\\"\t\b\r\n"], {"A"=>"\\'\\t\\b\\r\\n", "B"=>"\\\"\t\b\r\n"}, ["\\'\\t\\b\\r\\n", "\\\"\t\b\r\n"], {"A"=>"\\'\\t\\b\\r\\n", "B"=>"\\\"\t\b\r\n"}]
1683
+ locations:
1684
+ - [ "/", 1, 1 ]
1685
+ - [ "/0", 2, 2 ]
1686
+ - [ "/0/0", 2, 4 ]
1687
+ - [ "/0/1", 3, 4 ]
1688
+ - [ "/1", 4, 3 ]
1689
+ - [ "/1/A", 4, 8 ]
1690
+ - [ "/1/B", 5, 8 ]
1691
+ - [ "/2", 6, 3 ]
1692
+ - [ "/2/0", 6, 4 ]
1693
+ - [ "/2/1", 6, 20 ]
1694
+ - [ "/3", 7, 3 ]
1695
+ - [ "/3/A", 7, 9 ]
1696
+ - [ "/3/B", 8, 9 ]
1697
+ ##
1698
+ ---
1699
+ name: str3
1700
+ desc: binary and unicode
1701
+ input: |
1702
+ -
1703
+ - "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"
1704
+ - "\u65e5\u672c\u8a9e"
1705
+ - 'A': "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"
1706
+ "B": "\u65e5\u672c\u8a9e"
1707
+ - ["\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e", "\u65e5\u672c\u8a9e"]
1708
+ - {'A': "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e",
1709
+ "B": "\u65e5\u672c\u8a9e" }
1710
+ expected: |
1711
+ [["\346\227\245\346\234\254\350\252\236", "\346\227\245\346\234\254\350\252\236"], {"A"=>"\346\227\245\346\234\254\350\252\236", "B"=>"\346\227\245\346\234\254\350\252\236"}, ["\346\227\245\346\234\254\350\252\236", "\346\227\245\346\234\254\350\252\236"], {"A"=>"\346\227\245\346\234\254\350\252\236", "B"=>"\346\227\245\346\234\254\350\252\236"}]
1712
+ locations:
1713
+ - [ "/", 1, 1 ]
1714
+ - [ "/0", 2, 2 ]
1715
+ - [ "/0/0", 2, 4 ]
1716
+ - [ "/0/1", 3, 4 ]
1717
+ - [ "/1", 4, 3 ]
1718
+ - [ "/1/A", 4, 8 ]
1719
+ - [ "/1/B", 5, 8 ]
1720
+ - [ "/2", 6, 3 ]
1721
+ - [ "/2/0", 6, 4 ]
1722
+ - [ "/2/1", 6, 44 ]
1723
+ - [ "/3", 7, 3 ]
1724
+ - [ "/3/A", 7, 9 ]
1725
+ - [ "/3/B", 8, 9 ]
1726
+ ##
1727
+ ---
1728
+ name: mapkey1
1729
+ desc: mapping key test
1730
+ input: |
1731
+ - key1: A
1732
+ - .key.2: B
1733
+ - key3*: C
1734
+ - :key4: D
1735
+ # - k:e:y:5: E
1736
+ expected*:
1737
+ ruby: |
1738
+ [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}]
1739
+ # [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}, {"k:e:y:5"=>"E"}]
1740
+ java: |
1741
+ [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}]
1742
+ # [{"key1"=>"A"}, {".key.2"=>"B"}, {"key3*"=>"C"}, {:key4=>"D"}, {"k:e:y:5"=>"E"}]
1743
+ locations:
1744
+ - [ "/", 1, 1 ]
1745
+ - [ "/0/key1", 1, 11 ]
1746
+ - [ "/1/.key.2", 2, 11 ]
1747
+ - [ "/2/key3*", 3, 11 ]
1748
+ - [ "/3/:key4", 4, 11 ]
1749
+ ##