kwalify 0.4.1 → 0.5.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.
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 35 $
3
- ### $Release: 0.4.1 $
2
+ ### $Rev: 42 $
3
+ ### $Release: 0.5.0 $
4
4
  ### copyright(c) 2005 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
@@ -19,9 +19,9 @@ require 'pp'
19
19
  require 'stringio'
20
20
 
21
21
 
22
- class ParserTest < Test::Unit::TestCase
22
+ class YamlParserTest < Test::Unit::TestCase
23
23
  def _test()
24
- parser = Kwalify::Parser.new(@input)
24
+ parser = Kwalify::YamlParser.new(@input)
25
25
  if @error_class
26
26
  assert_raise(@error_class) do
27
27
  doc = parser.parse()
@@ -75,7 +75,7 @@ class ParserTest < Test::Unit::TestCase
75
75
  end
76
76
 
77
77
  #if $0 == __FILE__
78
- # Test::Unit::UI::Console::TestRunner.run(ParserTest)
78
+ # Test::Unit::UI::Console::TestRunner.run(YamlParserTest)
79
79
  #end
80
80
 
81
81
  __END__
@@ -210,7 +210,7 @@ expected: |
210
210
  ---
211
211
  name: parse08
212
212
  desc: syntax error - invalid indent of sequence.
213
- error: Kwalify::ParseError
213
+ error: Kwalify::YamlSyntaxError
214
214
  #
215
215
  input: |
216
216
  - AAA
@@ -223,7 +223,7 @@ expected: |
223
223
  ---
224
224
  name: parse09
225
225
  desc: syntax error - sequence item is exepcted.
226
- error: Kwalify::ParseError
226
+ error: Kwalify::YamlSyntaxError
227
227
  #
228
228
  input: |
229
229
  -
@@ -363,7 +363,7 @@ expected: |
363
363
  ---
364
364
  name: parse18
365
365
  desc: parse error - invalid indent of mapping.
366
- error: Kwalify::ParseError
366
+ error: Kwalify::YamlSyntaxError
367
367
  #
368
368
  input: |
369
369
  A: 10
@@ -378,7 +378,7 @@ expected: |
378
378
  ---
379
379
  name: parse19
380
380
  desc: parse error - mapping item is expected.
381
- error: Kwalify::ParseError
381
+ error: Kwalify::YamlSyntaxError
382
382
  #
383
383
  input: |
384
384
  A:
@@ -570,7 +570,7 @@ expected: |
570
570
  name: flowseq4
571
571
  desc: invalid flow style seq (sequence item required (or last comma is extra).)
572
572
  mesg: sequence item required (or last comma is extra).
573
- error: Kwalify::ParseError
573
+ error: Kwalify::YamlSyntaxError
574
574
  #
575
575
  input: |
576
576
  A: [ [10,20], ]
@@ -581,7 +581,7 @@ expected: |
581
581
  name: flowseq5
582
582
  desc: invalid flow style seq (flow style sequence requires ']').
583
583
  mesg: flow style sequence requires ']'
584
- error: Kwalify::ParseError
584
+ error: Kwalify::YamlSyntaxError
585
585
  #
586
586
  input: |
587
587
  A: [ [10,20]
@@ -593,7 +593,7 @@ expected: |
593
593
  name: flowseq6
594
594
  desc: invalid flow style seq (flow style sequence requires ']').
595
595
  mesg: flow style sequence is closed but got ']'.
596
- error: Kwalify::ParseError
596
+ error: Kwalify::YamlSyntaxError
597
597
  #
598
598
  input: |
599
599
  [ 10 ]]
@@ -653,7 +653,7 @@ expected: |
653
653
  name: flowmap4
654
654
  desc: invalid flow style map (mapping item required (or last comma is extra).)
655
655
  mesg: mapping item required (or last comma is extra).
656
- error: Kwalify::ParseError
656
+ error: Kwalify::YamlSyntaxError
657
657
  #
658
658
  input: |
659
659
  - {A: 10, B: 20, }
@@ -664,7 +664,7 @@ expected: |
664
664
  name: flowmap5
665
665
  desc: invalid flow style map (flow style mapping requires '}').
666
666
  mesg: flow style mapping requires '}'
667
- error: Kwalify::ParseError
667
+ error: Kwalify::YamlSyntaxError
668
668
  #
669
669
  input: |
670
670
  - {A: { x: 10, y: 20 }
@@ -676,7 +676,7 @@ expected: |
676
676
  name: flowmap6
677
677
  desc: invalid flow style map (flow style mapping requires ']').
678
678
  mesg: flow style mapping is closed but got '}'.
679
- error: Kwalify::ParseError
679
+ error: Kwalify::YamlSyntaxError
680
680
  #
681
681
  input: |
682
682
  { x: 10 }}
@@ -972,8 +972,8 @@ expected: |
972
972
  ---
973
973
  name: anchor5
974
974
  desc: anchor not found
975
- error: Kwalify::ParseError
976
- mesg: anchor 'a2' not found (Kwalify::ParseError)
975
+ error: Kwalify::YamlSyntaxError
976
+ mesg: anchor 'a2' not found (Kwalify::YamlSyntaxError)
977
977
  #
978
978
  input: |
979
979
  - &a1 foo
@@ -0,0 +1,1080 @@
1
+ ##
2
+ ## $Rev: 42 $
3
+ ## $Release: 0.5.0 $
4
+ ## copyright(c) 2005 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
+ #
16
+ ---
17
+ name: sequence2
18
+ desc: nested sequence
19
+ input: |
20
+ - A
21
+ -
22
+ - B1
23
+ - B2
24
+ -
25
+ - B2.1
26
+ - B2.2
27
+ - C
28
+ expected: |
29
+ ["A", ["B1", "B2", ["B2.1", "B2.2"]], "C"]
30
+ #
31
+ ---
32
+ name: sequence3
33
+ desc: null item of sequence
34
+ input: |
35
+ - A
36
+ -
37
+ - C
38
+ -
39
+ -
40
+ -
41
+ - G
42
+ expected: |
43
+ ["A", nil, "C", nil, nil, nil, "G"]
44
+ #
45
+ ---
46
+ name: sequence4
47
+ desc: null item of nested sequence
48
+ #
49
+ input: |
50
+ -
51
+ -
52
+ -
53
+ -
54
+ -
55
+ -
56
+ #
57
+ expected: |
58
+ [[[nil, nil, nil]], nil]
59
+ #
60
+ ---
61
+ name: sequence5
62
+ desc: sequence with empty lines
63
+ input: |
64
+
65
+ - A
66
+
67
+ -
68
+
69
+
70
+ - B
71
+
72
+
73
+ -
74
+ expected: |
75
+ ["A", ["B"], nil]
76
+ #
77
+ ---
78
+ name: sequence6
79
+ desc: syntax error - invalid indent of sequence.
80
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
81
+ #
82
+ input: |
83
+ - AAA
84
+ - BBB1
85
+ - BBB2
86
+ - CCC
87
+ #
88
+ expected: |
89
+ #
90
+ ---
91
+ name: sequence7
92
+ desc: syntax error - sequence item is exepcted.
93
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
94
+ input: |
95
+ -
96
+ - a1
97
+ - a2
98
+ a3
99
+ -
100
+ - b1
101
+ - b2
102
+ b3
103
+ expected: |
104
+ #
105
+ ---
106
+ name: mapping1
107
+ desc: basic mapping
108
+ #
109
+ input: |
110
+ A: foo
111
+ B: bar
112
+ C : baz
113
+ #
114
+ expected: |
115
+ {"A"=>"foo", "B"=>"bar", "C"=>"baz"}
116
+ ---
117
+ name: mapping2
118
+ desc: nested mapping
119
+ input: |
120
+ A: 10
121
+ B:
122
+ B1:
123
+ B1-1: 21
124
+ B1-2: 22
125
+ B1-3: 23
126
+ C: 30
127
+ expected: |
128
+ {"A"=>10, "B"=>{"B1"=>{"B1-1"=>21, "B1-2"=>22, "B1-3"=>23}}, "C"=>30}
129
+ #
130
+ ---
131
+ name: mapping3
132
+ desc: null item in mapping
133
+ input: |
134
+ A:
135
+ B:
136
+ B1:
137
+ B1-2:
138
+ C:
139
+ expected: |
140
+ {"A"=>nil, "B"=>{"B1"=>{"B1-2"=>nil}}, "C"=>nil}
141
+ #
142
+ ---
143
+ name: mapping4
144
+ desc: mapping with empty lines
145
+ input: |
146
+
147
+ A: 1
148
+
149
+ B:
150
+
151
+
152
+ B1:
153
+
154
+
155
+
156
+ B1a: 2
157
+ C: 3
158
+
159
+ #
160
+ expected: |
161
+ {"A"=>1, "B"=>{"B1"=>{"B1a"=>2}}, "C"=>3}
162
+ #
163
+ ---
164
+ name: mapping5
165
+ desc: parse error - invalid indent of mapping.
166
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
167
+ input: |
168
+ A: 10
169
+ B: 20
170
+ B1: 21
171
+ B2: 22
172
+ C: 30
173
+ expected: |
174
+ #
175
+ ---
176
+ name: mapping6
177
+ desc: parse error - mapping item is expected.
178
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
179
+ input: |
180
+ A:
181
+ a1: 1
182
+ a2: 2
183
+ a3 3
184
+ B:
185
+ b1: 1
186
+ b2: 2
187
+ b3 3
188
+ expected: |
189
+ #
190
+ ---
191
+ name: combination1
192
+ desc: seq of mapping
193
+ #
194
+ input: |
195
+ -
196
+ x: 10
197
+ y: 20
198
+ -
199
+ x: 15
200
+ y: 25
201
+ #
202
+ expected: |
203
+ [{"x"=>10, "y"=>20}, {"x"=>15, "y"=>25}]
204
+ #
205
+ ---
206
+ name: combination2
207
+ desc: seq of mapping (in same line)
208
+ #
209
+ input: |
210
+ - x: 10
211
+ y: 20
212
+ - x: 15
213
+ y: 25
214
+ #
215
+ expected: |
216
+ [{"x"=>10, "y"=>20}, {"x"=>15, "y"=>25}]
217
+ #
218
+ ---
219
+ name: combination3
220
+ desc: seq of seq of seq
221
+ #
222
+ input: |
223
+ - - - a
224
+ - b
225
+ - - - c
226
+ - d
227
+ #
228
+ expected: |
229
+ [[["a", "b"]], [["c", "d"]]]
230
+ #
231
+ ---
232
+ name: combination4
233
+ desc: map of sequence
234
+ #
235
+ input: |
236
+ A:
237
+ - 1
238
+ - 2
239
+ - 3
240
+ B:
241
+ - 4
242
+ - 5
243
+ - 6
244
+ #
245
+ expected: |
246
+ {"A"=>[1, 2, 3], "B"=>[4, 5, 6]}
247
+ #
248
+ ---
249
+ name: combination5
250
+ desc: map of sequence (in same line)
251
+ #
252
+ input: |
253
+ A: - 1
254
+ - 2
255
+ - 3
256
+ B: - 4
257
+ - 5
258
+ - 6
259
+ #
260
+ expected: |
261
+ {"A"=>[1, 2, 3], "B"=>[4, 5, 6]}
262
+ ---
263
+ name: combination6
264
+ desc: map of map of map
265
+ #
266
+ input: |
267
+ A: a: 1: 100
268
+ 2: 200
269
+ B: b: 3: 300
270
+ 4: 400
271
+ #
272
+ expected: |
273
+ {"A"=>{"a"=>{1=>100, 2=>200}}, "B"=>{"b"=>{3=>300, 4=>400}}}
274
+ ---
275
+ name: comment1
276
+ desc: line comment
277
+ input: |
278
+ # comment
279
+ - A
280
+ - B
281
+ # comment
282
+ -
283
+ # comment
284
+ - C
285
+ #
286
+ expected: |
287
+ ["A", "B", ["C"]]
288
+ #
289
+ ---
290
+ name: comment2
291
+ desc: escape line comment
292
+ #
293
+ input: |
294
+ # comment
295
+ - A
296
+ - B:
297
+ "# comment"
298
+ -
299
+ '# comment'
300
+ #
301
+ expected: |
302
+ ["A", {"B"=>"# comment"}, "# comment"]
303
+ #
304
+ ---
305
+ name: comment3
306
+ desc: line comment with seq and map
307
+ #
308
+ input: |
309
+ - A # comment
310
+ - B: # comment
311
+ C: foo # comment
312
+ D: "bar#bar" #comment
313
+ #
314
+ expected: |
315
+ ["A", {"B"=>{"C"=>"foo", "D"=>"bar#bar"}}]
316
+ #
317
+ ---
318
+ name: comment4
319
+ desc: line comment with anchor and alias
320
+ #
321
+ input: |
322
+ - &a1 # comment
323
+ foo
324
+ - *a1 # comment
325
+ #
326
+ expected: |
327
+ ["foo", "foo"]
328
+ #
329
+ ---
330
+ name: flowseq1
331
+ desc: flow style sequence
332
+ #
333
+ input: |
334
+ - [ 10, 20 ]
335
+ - [15,25,35]
336
+ #
337
+ expected: |
338
+ [[10, 20], [15, 25, 35]]
339
+ #
340
+ ---
341
+ name: flowseq2
342
+ desc: nested flow style sequence
343
+ #
344
+ input: |
345
+ 1: [ A, [B1, B2]]
346
+ 2: [[[X]]]
347
+ 3: [[1,1],[2,"2"],['3',3]]
348
+ #
349
+ expected: |
350
+ {1=>["A", ["B1", "B2"]], 2=>[[["X"]]], 3=>[[1, 1], [2, "2"], ["3", 3]]}
351
+ #expected: |
352
+ # {1=>["A", ["B1", "B2"]],
353
+ # 2=>[[["X"]]],
354
+ # 3=>[["x1", "y1"], ["x2", "y2"], ["x3", "y3"]]}
355
+ #
356
+ ---
357
+ name: flowseq3
358
+ desc: flow style sequence with some lines
359
+ #
360
+ input: |
361
+ A: [ [10,20],
362
+ [11,21],
363
+ [12,22]]
364
+ B: [
365
+ [1.1,
366
+ 1.2,
367
+ 1.3
368
+ ]
369
+ ]
370
+ #
371
+ expected: |
372
+ {"A"=>[[10, 20], [11, 21], [12, 22]], "B"=>[[1.1, 1.2, 1.3]]}
373
+ #
374
+ ---
375
+ name: flowseq4
376
+ desc: invalid flow style seq (sequence item required (or last comma is extra).)
377
+ mesg: sequence item required (or last comma is extra).
378
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
379
+ #
380
+ input: |
381
+ A: [ [10,20], ]
382
+ #
383
+ expected: |
384
+ #
385
+ ---
386
+ name: flowseq5
387
+ desc: invalid flow style seq (flow style sequence requires ']').
388
+ mesg: flow style sequence requires ']'
389
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
390
+ #
391
+ input: |
392
+ A: [ [10,20]
393
+ B: [ [30, 40]]
394
+ #
395
+ expected: |
396
+ #
397
+ ---
398
+ name: flowseq6
399
+ desc: invalid flow style seq (flow style sequence requires ']').
400
+ mesg: flow style sequence is closed but got ']'.
401
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
402
+ #
403
+ input: |
404
+ [ 10 ]]
405
+ #
406
+ expected: |
407
+ #
408
+ ---
409
+ name: flowmap1
410
+ desc: flow style map
411
+ #
412
+ input: |
413
+ - { A1: 10, A2: 20 }
414
+ - {B1: 15, 'B2': 25, "B3": 35}
415
+ #
416
+ expected: |
417
+ [{"A1"=>10, "A2"=>20}, {"B1"=>15, "B2"=>25, "B3"=>35}]
418
+ #
419
+ ---
420
+ name: flowmap2
421
+ desc: flow style map nested
422
+ #
423
+ input: |
424
+ A: { x: {y: {z: 10}}}
425
+ B: { a: 1, b:{c: 2, d: 3, e:{f: 4}}, g: 5}
426
+ #
427
+ expected: |
428
+ {"A"=>{"x"=>{"y"=>{"z"=>10}}}, "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
429
+ #
430
+ ---
431
+ name: flowmap3
432
+ desc: flow style map with some lines
433
+ #
434
+ input: |
435
+ A: { x:
436
+ {y:
437
+ {z: 10}
438
+ }
439
+ }
440
+ B: {
441
+ a: 1,
442
+ b: {
443
+ c: 2,
444
+ d: 3,
445
+ e: {
446
+ f: 4
447
+ }
448
+ },
449
+ g: 5
450
+ }
451
+ #
452
+ expected: |
453
+ {"A"=>{"x"=>{"y"=>{"z"=>10}}}, "B"=>{"a"=>1, "b"=>{"c"=>2, "d"=>3, "e"=>{"f"=>4}}, "g"=>5}}
454
+ #
455
+ ---
456
+ name: flowmap4
457
+ desc: invalid flow style map (mapping item required (or last comma is extra).)
458
+ mesg: mapping item required (or last comma is extra).
459
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
460
+ #
461
+ input: |
462
+ - {A: 10, B: 20, }
463
+ #
464
+ expected: |
465
+ #
466
+ ---
467
+ name: flowmap5
468
+ desc: invalid flow style map (flow style mapping requires '}').
469
+ mesg: flow style mapping requires '}'
470
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
471
+ #
472
+ input: |
473
+ - {A: { x: 10, y: 20 }
474
+ - {A: { x: 11, y: 21 }}
475
+ #
476
+ expected: |
477
+ #
478
+ ---
479
+ name: flowmap6
480
+ desc: invalid flow style map (flow style mapping requires ']').
481
+ mesg: flow style mapping is closed but got '}'.
482
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
483
+ #
484
+ input: |
485
+ { x: 10 }}
486
+ #
487
+ expected: |
488
+ #
489
+ ---
490
+ name: flowcombination1
491
+ desc: combination of flow style seq and map
492
+ #
493
+ input: |
494
+ [
495
+ {name: ' foo ',
496
+ e-mail: foo@mail.com},
497
+ {name: ba z,
498
+ e-mail: ba__z@mail.com }
499
+ ]
500
+ #
501
+ expected: |
502
+ [{"e-mail"=>"foo@mail.com", "name"=>" foo "}, {"e-mail"=>"ba__z@mail.com", "name"=>"ba z"}]
503
+ #
504
+ ---
505
+ name: blocktext01
506
+ desc: parse_blocktext
507
+ #
508
+ input: |
509
+ - text1: |
510
+ foo
511
+ bar
512
+ baz
513
+ - text2: |
514
+ aaa
515
+ bbb
516
+ ccc
517
+ - |
518
+ foo
519
+ bar
520
+ baz
521
+ - |
522
+ aaa
523
+ bbb
524
+ ccc
525
+ #
526
+ expected: |
527
+ [{"text1"=>"foo\nbar\nbaz\n"}, {"text2"=>"aaa\n bbb\n ccc\n"}, "foo\nbar\nbaz\n", "aaa\n bbb\n ccc\n"]
528
+ #
529
+ ---
530
+ name: blocktext02
531
+ desc: block text with '|+' or '|-'
532
+ #
533
+ input: |
534
+ - text1: |
535
+ A
536
+
537
+ B
538
+ C
539
+
540
+
541
+ - text2: |+
542
+ A
543
+
544
+ B
545
+ C
546
+
547
+
548
+ - text3: |-
549
+ A
550
+
551
+ B
552
+ C
553
+
554
+
555
+ #
556
+ expected: |
557
+ [{"text1"=>"A\n\nB\nC\n"}, {"text2"=>"A\n\nB\nC\n\n\n"}, {"text3"=>"A\n\nB\nC"}]
558
+ #
559
+ ---
560
+ name: blocktext03
561
+ desc: block text with '|n'
562
+ #
563
+ input: |
564
+ - text1: |2
565
+ A
566
+
567
+ B
568
+ C
569
+
570
+
571
+ - text2: |+2
572
+ A
573
+
574
+ B
575
+ C
576
+
577
+
578
+ - text3: |-2
579
+ A
580
+
581
+ B
582
+ C
583
+
584
+
585
+ #
586
+ expected: |
587
+ [{"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"}]
588
+ #
589
+ ---
590
+ name: blocktext04
591
+ desc: block text with '| foo'
592
+ #
593
+ input: |
594
+ - text1: | foo
595
+ A
596
+
597
+ B
598
+ C
599
+
600
+ - | foo
601
+ A
602
+ B
603
+ C
604
+ #
605
+ expected: |
606
+ [{"text1"=>"foo A\n\nB\nC\n"}, "fooA\n B\n C\n"]
607
+ #
608
+ ---
609
+ name: blocktext05
610
+ desc: block text with '#' (comment)
611
+ #
612
+ input: |
613
+ #
614
+ - text1: |
615
+ A
616
+ #
617
+ B
618
+ #
619
+ text2: |
620
+ #
621
+ #
622
+ #
623
+ - |
624
+ A
625
+ #
626
+ B
627
+ #
628
+ - |
629
+ #
630
+ #
631
+ #
632
+ - x
633
+
634
+ #
635
+ expected: |
636
+ [{"text1"=>"A\n#\nB\n", "text2"=>"#\n#\n"}, "A\n#\nB\n", "#\n#\n", "x"]
637
+ #
638
+ ---
639
+ name: blocktext06
640
+ desc: invalid block text
641
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
642
+ #
643
+ input: |
644
+ - |
645
+ a
646
+ b
647
+ c
648
+ #
649
+ expected: |
650
+ #
651
+ ---
652
+ name: blocktext11
653
+ desc: parse_blocktext (>)
654
+ #
655
+ input: |
656
+ - text1: >
657
+ foo
658
+ bar
659
+ baz
660
+ - text2: >
661
+ aaa
662
+ bbb
663
+ ccc
664
+ - >
665
+ foo
666
+ bar
667
+ baz
668
+ - >
669
+ aaa
670
+ bbb
671
+ ccc
672
+ #
673
+ expected: |
674
+ [{"text1"=>"foo bar baz\n"}, {"text2"=>"aaa bbb ccc\n"}, "foo bar baz\n", "aaa bbb ccc\n"]
675
+ #
676
+ ---
677
+ name: blocktext12
678
+ desc: block text with '>+' or '>-'
679
+ #
680
+ input: |
681
+ - text1: >
682
+ A
683
+
684
+ B
685
+ C
686
+
687
+
688
+ - text2: >+
689
+ A
690
+
691
+ B
692
+ C
693
+
694
+
695
+ - text3: >-
696
+ A
697
+
698
+ B
699
+ C
700
+
701
+
702
+ #
703
+ expected: |
704
+ [{"text1"=>"A\nB C\n"}, {"text2"=>"A\nB C\n\n\n"}, {"text3"=>"A\nB C"}]
705
+ #
706
+ ---
707
+ name: blocktext13
708
+ desc: block text with '>n'
709
+ #
710
+ input: |
711
+ - >2
712
+ A
713
+
714
+ B
715
+ C
716
+
717
+
718
+ - >+2
719
+ A
720
+
721
+ B
722
+ C
723
+
724
+
725
+ - >-2
726
+ A
727
+
728
+ B
729
+ C
730
+
731
+
732
+ #
733
+ expected: |
734
+ [" A\n B C\n", " A\n B C\n\n\n", " A\n B C"]
735
+ # [" A\n\n B\n C\n", " A\n\n B\n C\n\n\n", " A\n\n B\n C"]
736
+ #
737
+ ---
738
+ name: blocktext14
739
+ desc: block text with '> foo'
740
+ #
741
+ input: |
742
+ - text1: > foo
743
+ A
744
+
745
+ B
746
+ C
747
+
748
+ - > foo
749
+ A
750
+ B
751
+ C
752
+ #
753
+ expected: |
754
+ [{"text1"=>"foo A\nB C\n"}, "fooA B C\n"]
755
+ #
756
+ ---
757
+ name: blocktext15
758
+ desc: block text with '#' (comment)
759
+ #
760
+ input: |
761
+ #
762
+ - text1: >
763
+ AA
764
+ ##
765
+ BB
766
+ #
767
+ text2: >
768
+ #
769
+ #
770
+ #
771
+ - >
772
+ AA
773
+ ##
774
+ BB
775
+ #
776
+ - >
777
+ #
778
+ #
779
+ #
780
+ - x
781
+
782
+ #
783
+ expected: |
784
+ [{"text1"=>"AA ## BB\n", "text2"=>"# #\n"}, "AA ## BB\n", "# #\n", "x"]
785
+ #
786
+ ---
787
+ name: blocktext16
788
+ desc: invalid block text
789
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
790
+ #
791
+ input: |
792
+ - >
793
+ a
794
+ b
795
+ c
796
+ #
797
+ expected: |
798
+ #
799
+ ---
800
+ name: anchor1
801
+ desc: parse_anchor, parse_alias
802
+ #
803
+ input: |
804
+ - &a1 foo
805
+ - &a2
806
+ bar
807
+ - *a1
808
+ - *a2
809
+ #
810
+ expected: |
811
+ ["foo", "bar", "foo", "bar"]
812
+ #
813
+ ---
814
+ name: anchor2
815
+ desc: parse_anchor, parse_alias
816
+ #
817
+ input: |
818
+ - A: &a1
819
+ x: 10
820
+ y: 20
821
+ - B: bar
822
+ - C: *a1
823
+ #
824
+ expected: |
825
+ [{"A"=>{"x"=>10, "y"=>20}}, {"B"=>"bar"}, {"C"=>{"x"=>10, "y"=>20}}]
826
+ #
827
+ ---
828
+ name: anchor3
829
+ desc: anchor on child node
830
+ #
831
+ input: |
832
+ - A: &a1
833
+ x: 10
834
+ y: 20
835
+ z: *a1
836
+ #
837
+ expected: |
838
+ [{"A"=>{"x"=>10, "y"=>20, "z"=>{...}}}]
839
+ #
840
+ ---
841
+ name: anchor4
842
+ desc: backward anchor
843
+ #
844
+ input: |
845
+ - *a1
846
+ - *a1
847
+ - foo
848
+ - &a1 bar
849
+ #
850
+ expected: |
851
+ ["bar", "bar", "foo", "bar"]
852
+ #
853
+ ---
854
+ name: anchor5
855
+ desc: anchor not found
856
+ exception*: { ruby: Kwalify::ParseError, java: kwalify.SyntaxException }
857
+ mesg: anchor 'a2' not found (Kwalify::ParseError)
858
+ #
859
+ input: |
860
+ - &a1 foo
861
+ - bar
862
+ - *a2
863
+ #
864
+ expected: |
865
+ #
866
+ ---
867
+ name: anchor6
868
+ desc: anchor on child node
869
+ #
870
+ input: |
871
+ type: seq
872
+ sequence:
873
+ - &employee
874
+ type: map
875
+ mapping:
876
+ name:
877
+ type: str
878
+ post:
879
+ type: str
880
+ enum:
881
+ - exective
882
+ - manager
883
+ - clerk
884
+ supervisor: *employee
885
+ #
886
+ expected*:
887
+ ruby: |
888
+ {"sequence"=>
889
+ [{"type"=>"map",
890
+ "mapping"=>
891
+ {"name"=>{"type"=>"str"},
892
+ "post"=>{"type"=>"str", "enum"=>["exective", "manager", "clerk"]},
893
+ "supervisor"=>{...}}}],
894
+ "type"=>"seq"}
895
+ java: |
896
+ {"sequence"=>[{"mapping"=>{"name"=>{"type"=>"str"}, "post"=>{"enum"=>["exective", "manager", "clerk"], "type"=>"str"}, "supervisor"=>{...}}, "type"=>"map"}], "type"=>"seq"}
897
+ #
898
+ ---
899
+ name: tag1
900
+ desc: tag
901
+ #
902
+ input: |
903
+ - !str 123
904
+ - foo: !text 123
905
+ #
906
+ expected: |
907
+ [123, {"foo"=>123}]
908
+ #
909
+ ---
910
+ name: docend1
911
+ desc: ... (document end)
912
+ #
913
+ input: |
914
+ - aaa
915
+ - bbb
916
+ ...
917
+ - ccc
918
+ #
919
+ expected: |
920
+ ["aaa", "bbb"]
921
+ #
922
+ ---
923
+ name: docend2
924
+ desc: ... (document end) in block text
925
+ #
926
+ input: |
927
+ - |
928
+ foo
929
+ ...
930
+ bar
931
+ #
932
+ expected: |
933
+ ["foo\n...\nbar\n"]
934
+ #
935
+ ---
936
+ name: docstart1
937
+ desc: --- (document start)
938
+ #
939
+ input: |
940
+ # comment
941
+ ---
942
+ - foo
943
+ - bar
944
+ #
945
+ expected: |
946
+ ["foo", "bar"]
947
+ #
948
+ ---
949
+ name: docstart2
950
+ desc: --- (document start) with tag
951
+ #
952
+ input: |
953
+ # comment
954
+ --- %YAML !seq
955
+ - foo
956
+ - bar
957
+ #
958
+ expected: |
959
+ ["foo", "bar"]
960
+ #
961
+ ---
962
+ name: docstart3
963
+ desc: --- (document start) with tag
964
+ #
965
+ input: |
966
+ - |
967
+ foo
968
+ ---
969
+ bar
970
+ ---
971
+ baz
972
+ #
973
+ expected: |
974
+ ["foo\n---\nbar\n---\nbaz\n"]
975
+ #
976
+ ---
977
+ name: default1
978
+ desc: map default value
979
+ #
980
+ input: |
981
+ - A: 10
982
+ B: 20
983
+ =: -1
984
+ - K:
985
+ x: 10
986
+ y: 20
987
+ =:
988
+ x: 0
989
+ y: 0
990
+ #
991
+ expected: |
992
+ [{"A"=>10, "B"=>20}, {"K"=>{"x"=>10, "y"=>20}}]
993
+ #
994
+ ---
995
+ name: merge1
996
+ desc: merge key '<<'
997
+ #
998
+ input: |
999
+ - &a1
1000
+ A: 10
1001
+ B: 20
1002
+ - C: 30
1003
+ <<: *a1
1004
+ A: ~
1005
+ #
1006
+ expected: |
1007
+ [{"A"=>10, "B"=>20}, {"A"=>nil, "B"=>20, "C"=>30}]
1008
+ ---
1009
+ name: scalar1
1010
+ desc: scalar with sequence
1011
+ input: |
1012
+ - abc
1013
+ - 123
1014
+ - 3.14
1015
+ - true
1016
+ - false
1017
+ - yes
1018
+ - no
1019
+ - ~
1020
+ - null
1021
+ - "123"
1022
+ - '456'
1023
+ - 2005-01-01
1024
+ - :sym
1025
+ expected*:
1026
+ ruby: |
1027
+ ["abc",
1028
+ 123,
1029
+ 3.14,
1030
+ true,
1031
+ false,
1032
+ true,
1033
+ false,
1034
+ nil,
1035
+ nil,
1036
+ "123",
1037
+ "456",
1038
+ #<Date: 4906743/2,0,2299161>,
1039
+ :sym]
1040
+ java: |
1041
+ ["abc", 123, 3.14, true, false, true, false, nil, nil, "123", "456", Tue Feb 01 00:00:00 JST 2005, ":sym"]
1042
+ # ["abc", 123, true, false, true, false, nil, nil, "123", "456", #<Date: 4906743/2,0,2299161>, :sym]
1043
+ #
1044
+ ---
1045
+ name: scalar2
1046
+ desc: mapping of scalar
1047
+ input: |
1048
+ - abc : ABC
1049
+ - 123 : 123
1050
+ - 3.14 : 3.14
1051
+ - true : true
1052
+ - false : false
1053
+ - yes : yes
1054
+ - no : no
1055
+ - ~ : ~
1056
+ - null : null
1057
+ - "123" : "123"
1058
+ - '456' : '456'
1059
+ - 2005-01-01 : 2005-01-01
1060
+ - :sym : :sym
1061
+ expected*:
1062
+ ruby: |
1063
+ [{"abc"=>"ABC"},
1064
+ {123=>123},
1065
+ {3.14=>3.14},
1066
+ {true=>true},
1067
+ {false=>false},
1068
+ {true=>true},
1069
+ {false=>false},
1070
+ {nil=>nil},
1071
+ {nil=>nil},
1072
+ {"123"=>"123"},
1073
+ {"456"=>"456"},
1074
+ {#<Date: 4906743/2,0,2299161>=>#<Date: 4906743/2,0,2299161>},
1075
+ {:sym=>:sym}]
1076
+ java: |
1077
+ [{"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"}]
1078
+ # {123=>1.23, 3.14=>314, "abc"=>"ABC"}
1079
+ # {"abc"=>"ABC", 3.14=>314, 123=>1.23}
1080
+