Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / yaml / Tests / Fixtures / YtsSpecificationExamples.yml
1 --- %YAML:1.0
2 test: Sequence of scalars
3 spec: 2.1
4 yaml: |
5   - Mark McGwire
6   - Sammy Sosa
7   - Ken Griffey
8 php: |
9   array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey')
10 ---
11 test: Mapping of scalars to scalars
12 spec: 2.2
13 yaml: |
14   hr:  65
15   avg: 0.278
16   rbi: 147
17 php: |
18   array('hr' => 65, 'avg' => 0.278, 'rbi' => 147)
19 ---
20 test: Mapping of scalars to sequences
21 spec: 2.3
22 yaml: |
23     american:
24        - Boston Red Sox
25        - Detroit Tigers
26        - New York Yankees
27     national:
28        - New York Mets
29        - Chicago Cubs
30        - Atlanta Braves
31 php: |
32     array('american' =>
33         array( 'Boston Red Sox', 'Detroit Tigers',
34           'New York Yankees' ),
35       'national' =>
36         array( 'New York Mets', 'Chicago Cubs',
37           'Atlanta Braves' )
38     )
39 ---
40 test: Sequence of mappings
41 spec: 2.4
42 yaml: |
43     -
44       name: Mark McGwire
45       hr:   65
46       avg:  0.278
47     -
48       name: Sammy Sosa
49       hr:   63
50       avg:  0.288
51 php: |
52     array(
53       array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278),
54       array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288)
55     )
56 ---
57 test: Legacy A5
58 todo: true
59 spec: legacy_A5
60 yaml: |
61     ?
62         - New York Yankees
63         - Atlanta Braves
64     :
65       - 2001-07-02
66       - 2001-08-12
67       - 2001-08-14
68     ?
69         - Detroit Tigers
70         - Chicago Cubs
71     :
72       - 2001-07-23
73 perl-busted: >
74     YAML.pm will be able to emulate this behavior soon. In this regard
75     it may be somewhat more correct than Python's native behaviour which
76     can only use tuples as mapping keys. PyYAML will also need to figure
77     out some clever way to roundtrip structured keys.
78 python: |
79     [
80     {
81         ('New York Yankees', 'Atlanta Braves'):
82             [yaml.timestamp('2001-07-02'),
83              yaml.timestamp('2001-08-12'),
84              yaml.timestamp('2001-08-14')],
85         ('Detroit Tigers', 'Chicago Cubs'):
86         [yaml.timestamp('2001-07-23')]
87     }
88     ]
89 ruby: |
90     {
91       [ 'New York Yankees', 'Atlanta Braves' ] =>
92         [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ],
93       [ 'Detroit Tigers', 'Chicago Cubs' ] =>
94         [ Date.new( 2001, 7, 23 ) ]
95     }
96 syck: |
97   struct test_node seq1[] = {
98       { T_STR, 0, "New York Yankees" },
99       { T_STR, 0, "Atlanta Braves" },
100       end_node
101   };
102   struct test_node seq2[] = {
103       { T_STR, 0, "2001-07-02" },
104       { T_STR, 0, "2001-08-12" },
105       { T_STR, 0, "2001-08-14" },
106       end_node
107   };
108   struct test_node seq3[] = {
109       { T_STR, 0, "Detroit Tigers" },
110       { T_STR, 0, "Chicago Cubs" },
111       end_node
112   };
113   struct test_node seq4[] = {
114       { T_STR, 0, "2001-07-23" },
115       end_node
116   };
117   struct test_node map[] = {
118       { T_SEQ, 0, 0, seq1 },
119       { T_SEQ, 0, 0, seq2 },
120       { T_SEQ, 0, 0, seq3 },
121       { T_SEQ, 0, 0, seq4 },
122       end_node
123   };
124   struct test_node stream[] = {
125       { T_MAP, 0, 0, map },
126       end_node
127   };
128
129 ---
130 test: Sequence of sequences
131 spec: 2.5
132 yaml: |
133   - [ name         , hr , avg   ]
134   - [ Mark McGwire , 65 , 0.278 ]
135   - [ Sammy Sosa   , 63 , 0.288 ]
136 php: |
137   array(
138     array( 'name', 'hr', 'avg' ),
139     array( 'Mark McGwire', 65, 0.278 ),
140     array( 'Sammy Sosa', 63, 0.288 )
141   )
142 ---
143 test: Mapping of mappings
144 todo: true
145 spec: 2.6
146 yaml: |
147   Mark McGwire: {hr: 65, avg: 0.278}
148   Sammy Sosa: {
149       hr: 63,
150       avg: 0.288
151     }
152 php: |
153   array(
154     'Mark McGwire' =>
155       array( 'hr' => 65, 'avg' => 0.278 ),
156     'Sammy Sosa' =>
157       array( 'hr' => 63, 'avg' => 0.288 )
158   )
159 ---
160 test: Two documents in a stream each with a leading comment
161 todo: true
162 spec: 2.7
163 yaml: |
164   # Ranking of 1998 home runs
165   ---
166   - Mark McGwire
167   - Sammy Sosa
168   - Ken Griffey
169
170   # Team ranking
171   ---
172   - Chicago Cubs
173   - St Louis Cardinals
174 ruby: |
175   y = YAML::Stream.new
176   y.add( [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] )
177   y.add( [ 'Chicago Cubs', 'St Louis Cardinals' ] )
178 documents: 2
179
180 ---
181 test: Play by play feed from a game
182 todo: true
183 spec: 2.8
184 yaml: |
185   ---
186   time: 20:03:20
187   player: Sammy Sosa
188   action: strike (miss)
189   ...
190   ---
191   time: 20:03:47
192   player: Sammy Sosa
193   action: grand slam
194   ...
195 perl: |
196   [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
197 documents: 2
198
199 ---
200 test: Single document with two comments
201 spec: 2.9
202 yaml: |
203   hr: # 1998 hr ranking
204     - Mark McGwire
205     - Sammy Sosa
206   rbi:
207     # 1998 rbi ranking
208     - Sammy Sosa
209     - Ken Griffey
210 php: |
211   array(
212     'hr' => array( 'Mark McGwire', 'Sammy Sosa' ),
213     'rbi' => array( 'Sammy Sosa', 'Ken Griffey' )
214   )
215 ---
216 test: Node for Sammy Sosa appears twice in this document
217 spec: 2.10
218 yaml: |
219    ---
220    hr:
221       - Mark McGwire
222       # Following node labeled SS
223       - &SS Sammy Sosa
224    rbi:
225       - *SS # Subsequent occurrence
226       - Ken Griffey
227 php: |
228    array(
229       'hr' =>
230          array('Mark McGwire', 'Sammy Sosa'),
231       'rbi' =>
232          array('Sammy Sosa', 'Ken Griffey')
233    )
234 ---
235 test: Mapping between sequences
236 todo: true
237 spec: 2.11
238 yaml: |
239    ? # PLAY SCHEDULE
240      - Detroit Tigers
241      - Chicago Cubs
242    :
243      - 2001-07-23
244
245    ? [ New York Yankees,
246        Atlanta Braves ]
247    : [ 2001-07-02, 2001-08-12,
248        2001-08-14 ]
249 ruby: |
250    {
251       [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
252       [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ]
253    }
254 syck: |
255   struct test_node seq1[] = {
256       { T_STR, 0, "New York Yankees" },
257       { T_STR, 0, "Atlanta Braves" },
258       end_node
259   };
260   struct test_node seq2[] = {
261       { T_STR, 0, "2001-07-02" },
262       { T_STR, 0, "2001-08-12" },
263       { T_STR, 0, "2001-08-14" },
264       end_node
265   };
266   struct test_node seq3[] = {
267       { T_STR, 0, "Detroit Tigers" },
268       { T_STR, 0, "Chicago Cubs" },
269       end_node
270   };
271   struct test_node seq4[] = {
272       { T_STR, 0, "2001-07-23" },
273       end_node
274   };
275   struct test_node map[] = {
276       { T_SEQ, 0, 0, seq3 },
277       { T_SEQ, 0, 0, seq4 },
278       { T_SEQ, 0, 0, seq1 },
279       { T_SEQ, 0, 0, seq2 },
280       end_node
281   };
282   struct test_node stream[] = {
283       { T_MAP, 0, 0, map },
284       end_node
285   };
286
287 ---
288 test: Sequence key shortcut
289 spec: 2.12
290 yaml: |
291   ---
292   # products purchased
293   - item    : Super Hoop
294     quantity: 1
295   - item    : Basketball
296     quantity: 4
297   - item    : Big Shoes
298     quantity: 1
299 php: |
300   array (
301     array (
302       'item' => 'Super Hoop',
303       'quantity' => 1,
304     ),
305     array (
306       'item' => 'Basketball',
307       'quantity' => 4,
308     ),
309     array (
310       'item' => 'Big Shoes',
311       'quantity' => 1,
312     )
313   )
314 perl: |
315   [
316      { item => 'Super Hoop', quantity => 1 },
317      { item => 'Basketball', quantity => 4 },
318      { item => 'Big Shoes',  quantity => 1 }
319   ]
320
321 ruby: |
322   [
323      { 'item' => 'Super Hoop', 'quantity' => 1 },
324      { 'item' => 'Basketball', 'quantity' => 4 },
325      { 'item' => 'Big Shoes', 'quantity' => 1 }
326   ]
327 python: |
328   [
329        { 'item': 'Super Hoop', 'quantity': 1 },
330        { 'item': 'Basketball', 'quantity': 4 },
331        { 'item': 'Big Shoes',  'quantity': 1 }
332   ]
333 syck: |
334   struct test_node map1[] = {
335       { T_STR, 0, "item" },
336           { T_STR, 0, "Super Hoop" },
337       { T_STR, 0, "quantity" },
338           { T_STR, 0, "1" },
339       end_node
340   };
341   struct test_node map2[] = {
342       { T_STR, 0, "item" },
343           { T_STR, 0, "Basketball" },
344       { T_STR, 0, "quantity" },
345           { T_STR, 0, "4" },
346       end_node
347   };
348   struct test_node map3[] = {
349       { T_STR, 0, "item" },
350           { T_STR, 0, "Big Shoes" },
351       { T_STR, 0, "quantity" },
352           { T_STR, 0, "1" },
353       end_node
354   };
355   struct test_node seq[] = {
356       { T_MAP, 0, 0, map1 },
357       { T_MAP, 0, 0, map2 },
358       { T_MAP, 0, 0, map3 },
359       end_node
360   };
361   struct test_node stream[] = {
362       { T_SEQ, 0, 0, seq },
363       end_node
364   };
365
366
367 ---
368 test: Literal perserves newlines
369 todo: true
370 spec: 2.13
371 yaml: |
372   # ASCII Art
373   --- |
374     \//||\/||
375     // ||  ||_
376 perl: |
377   "\\//||\\/||\n// ||  ||_\n"
378 ruby: |
379   "\\//||\\/||\n// ||  ||_\n"
380 python: |
381     [
382         flushLeft(
383         """
384         \//||\/||
385         // ||  ||_
386         """
387         )
388     ]
389 syck: |
390   struct test_node stream[] = {
391       { T_STR, 0, "\\//||\\/||\n// ||  ||_\n" },
392       end_node
393   };
394
395 ---
396 test: Folded treats newlines as a space
397 todo: true
398 spec: 2.14
399 yaml: |
400   ---
401     Mark McGwire's
402     year was crippled
403     by a knee injury.
404 perl: |
405   "Mark McGwire's year was crippled by a knee injury."
406 ruby: |
407   "Mark McGwire's year was crippled by a knee injury."
408 python: |
409     [ "Mark McGwire's year was crippled by a knee injury." ]
410 syck: |
411   struct test_node stream[] = {
412       { T_STR, 0, "Mark McGwire's year was crippled by a knee injury." },
413       end_node
414   };
415
416 ---
417 test: Newlines preserved for indented and blank lines
418 todo: true
419 spec: 2.15
420 yaml: |
421   --- >
422    Sammy Sosa completed another
423    fine season with great stats.
424
425      63 Home Runs
426      0.288 Batting Average
427
428    What a year!
429 perl: |
430   "Sammy Sosa completed another fine season with great stats.\n\n  63 Home Runs\n  0.288 Batting Average\n\nWhat a year!\n"
431 ruby: |
432   "Sammy Sosa completed another fine season with great stats.\n\n  63 Home Runs\n  0.288 Batting Average\n\nWhat a year!\n"
433 python: |
434     [
435         flushLeft(
436         """
437         Sammy Sosa completed another fine season with great stats.
438
439           63 Home Runs
440           0.288 Batting Average
441
442         What a year!
443         """
444         )
445     ]
446 syck: |
447   struct test_node stream[] = {
448       { T_STR, 0, "Sammy Sosa completed another fine season with great stats.\n\n  63 Home Runs\n  0.288 Batting Average\n\nWhat a year!\n" },
449       end_node
450   };
451
452
453 ---
454 test: Indentation determines scope
455 spec: 2.16
456 yaml: |
457   name: Mark McGwire
458   accomplishment: >
459      Mark set a major league
460      home run record in 1998.
461   stats: |
462      65 Home Runs
463      0.278 Batting Average
464 php: |
465   array(
466     'name' => 'Mark McGwire',
467     'accomplishment' => "Mark set a major league home run record in 1998.\n",
468     'stats' => "65 Home Runs\n0.278 Batting Average\n"
469   )
470 ---
471 test: Quoted scalars
472 todo: true
473 spec: 2.17
474 yaml: |
475   unicode: "Sosa did fine.\u263A"
476   control: "\b1998\t1999\t2000\n"
477   hexesc:  "\x0D\x0A is \r\n"
478
479   single: '"Howdy!" he cried.'
480   quoted: ' # not a ''comment''.'
481   tie-fighter: '|\-*-/|'
482 ruby: |
483   {
484     "tie-fighter" => "|\\-*-/|",
485     "control"=>"\0101998\t1999\t2000\n",
486     "unicode"=>"Sosa did fine." + ["263A".hex ].pack('U*'),
487     "quoted"=>" # not a 'comment'.",
488     "single"=>"\"Howdy!\" he cried.",
489     "hexesc"=>"\r\n is \r\n"
490   }
491 ---
492 test: Multiline flow scalars
493 todo: true
494 spec: 2.18
495 yaml: |
496   plain:
497     This unquoted scalar
498     spans many lines.
499
500   quoted: "So does this
501     quoted scalar.\n"
502 ruby: |
503   {
504     'plain' => 'This unquoted scalar spans many lines.',
505     'quoted' => "So does this quoted scalar.\n"
506   }
507 ---
508 test: Integers
509 spec: 2.19
510 yaml: |
511   canonical: 12345
512   octal: 014
513   hexadecimal: 0xC
514 php: |
515   array(
516     'canonical' => 12345,
517     'octal' => 014,
518     'hexadecimal' => 0xC
519   )
520 ---
521 test: Decimal Integer
522 deprecated: true
523 spec: 2.19
524 yaml: |
525   decimal: +12,345
526 php: |
527   array(
528     'decimal' => 12345.0,
529   )
530 ---
531 # FIX: spec shows parens around -inf and NaN
532 test: Floating point
533 spec: 2.20
534 yaml: |
535   canonical: 1.23015e+3
536   exponential: 12.3015e+02
537   negative infinity: -.inf
538   not a number: .NaN
539   float as whole number: !!float 1
540 php: |
541   array(
542     'canonical' => 1230.15,
543     'exponential' => 1230.15,
544     'negative infinity' => log(0),
545     'not a number' => -log(0),
546     'float as whole number' => (float) 1
547   )
548 ---
549 test: Fixed Floating point
550 deprecated: true
551 spec: 2.20
552 yaml: |
553   fixed: 1,230.15
554 php: |
555   array(
556     'fixed' => 1230.15,
557   )
558 ---
559 test: Miscellaneous
560 spec: 2.21
561 yaml: |
562   null: ~
563   true: true
564   false: false
565   string: '12345'
566 php: |
567   array(
568     '' => null,
569     1 => true,
570     0 => false,
571     'string' => '12345'
572   )
573 ---
574 test: Timestamps
575 todo: true
576 spec: 2.22
577 yaml: |
578   canonical: 2001-12-15T02:59:43.1Z
579   iso8601:  2001-12-14t21:59:43.10-05:00
580   spaced:  2001-12-14 21:59:43.10 -05:00
581   date:   2002-12-14 # Time is noon UTC
582 php: |
583   array(
584     'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
585     'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
586     'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
587     'date' => Date.new( 2002, 12, 14 )
588   )
589 ---
590 test: legacy Timestamps test
591 todo: true
592 spec: legacy D4
593 yaml: |
594     canonical: 2001-12-15T02:59:43.00Z
595     iso8601:  2001-02-28t21:59:43.00-05:00
596     spaced:  2001-12-14 21:59:43.00 -05:00
597     date:   2002-12-14
598 php: |
599    array(
600      'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
601      'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
602      'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
603      'date' => Date.new( 2002, 12, 14 )
604    )
605 ---
606 test: Various explicit families
607 todo: true
608 spec: 2.23
609 yaml: |
610   not-date: !str 2002-04-28
611   picture: !binary |
612    R0lGODlhDAAMAIQAAP//9/X
613    17unp5WZmZgAAAOfn515eXv
614    Pz7Y6OjuDg4J+fn5OTk6enp
615    56enmleECcgggoBADs=
616
617   application specific tag: !!something |
618    The semantics of the tag
619    above may be different for
620    different documents.
621
622 ruby-setup: |
623   YAML.add_private_type( "something" ) do |type, val|
624     "SOMETHING: #{val}"
625   end
626 ruby: |
627   {
628     'not-date' => '2002-04-28',
629     'picture' => "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236i^\020' \202\n\001\000;",
630     'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n"
631   }
632 ---
633 test: Application specific family
634 todo: true
635 spec: 2.24
636 yaml: |
637   # Establish a tag prefix
638   --- !clarkevans.com,2002/graph/^shape
639     # Use the prefix: shorthand for
640     # !clarkevans.com,2002/graph/circle
641   - !^circle
642     center: &ORIGIN {x: 73, 'y': 129}
643     radius: 7
644   - !^line # !clarkevans.com,2002/graph/line
645     start: *ORIGIN
646     finish: { x: 89, 'y': 102 }
647   - !^label
648     start: *ORIGIN
649     color: 0xFFEEBB
650     value: Pretty vector drawing.
651 ruby-setup: |
652   YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
653     if Array === val
654       val << "Shape Container"
655       val
656     else
657       raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
658     end
659   }
660   one_shape_proc = Proc.new { |type, val|
661     scheme, domain, type = type.split( /:/, 3 )
662     if val.is_a? ::Hash
663       val['TYPE'] = "Shape: #{type}"
664       val
665     else
666       raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
667     end
668   }
669   YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
670   YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
671   YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc )
672 ruby: |
673   [
674     {
675       "radius" => 7,
676       "center"=>
677       {
678         "x" => 73,
679         "y" => 129
680       },
681       "TYPE" => "Shape: graph/circle"
682     }, {
683       "finish" =>
684       {
685         "x" => 89,
686         "y" => 102
687       },
688       "TYPE" => "Shape: graph/line",
689       "start" =>
690       {
691         "x" => 73,
692         "y" => 129
693       }
694     }, {
695       "TYPE" => "Shape: graph/label",
696       "value" => "Pretty vector drawing.",
697       "start" =>
698       {
699         "x" => 73,
700         "y" => 129
701       },
702       "color" => 16772795
703     },
704     "Shape Container"
705   ]
706 # ---
707 # test: Unordered set
708 # spec: 2.25
709 # yaml: |
710 #   # sets are represented as a
711 #   # mapping where each key is
712 #   # associated with the empty string
713 #   --- !set
714 #   ? Mark McGwire
715 #   ? Sammy Sosa
716 #   ? Ken Griff
717 ---
718 test: Ordered mappings
719 todo: true
720 spec: 2.26
721 yaml: |
722   # ordered maps are represented as
723   # a sequence of mappings, with
724   # each mapping having one key
725   --- !omap
726   - Mark McGwire: 65
727   - Sammy Sosa: 63
728   - Ken Griffy: 58
729 ruby: |
730   YAML::Omap[
731     'Mark McGwire', 65,
732     'Sammy Sosa', 63,
733     'Ken Griffy', 58
734   ]
735 ---
736 test: Invoice
737 dump_skip: true
738 spec: 2.27
739 yaml: |
740   --- !clarkevans.com,2002/^invoice
741   invoice: 34843
742   date   : 2001-01-23
743   bill-to: &id001
744       given  : Chris
745       family : Dumars
746       address:
747           lines: |
748               458 Walkman Dr.
749               Suite #292
750           city    : Royal Oak
751           state   : MI
752           postal  : 48046
753   ship-to: *id001
754   product:
755       -
756         sku         : BL394D
757         quantity    : 4
758         description : Basketball
759         price       : 450.00
760       -
761         sku         : BL4438H
762         quantity    : 1
763         description : Super Hoop
764         price       : 2392.00
765   tax  : 251.42
766   total: 4443.52
767   comments: >
768     Late afternoon is best.
769     Backup contact is Nancy
770     Billsmer @ 338-4338.
771 php: |
772   array(
773      'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
774      'bill-to' =>
775       array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
776      , 'ship-to' =>
777       array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
778      , 'product' =>
779        array(
780         array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ),
781         array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 )
782       ),
783      'tax' => 251.42, 'total' => 4443.52,
784      'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n"
785   )
786 ---
787 test: Log file
788 todo: true
789 spec: 2.28
790 yaml: |
791   ---
792   Time: 2001-11-23 15:01:42 -05:00
793   User: ed
794   Warning: >
795     This is an error message
796     for the log file
797   ---
798   Time: 2001-11-23 15:02:31 -05:00
799   User: ed
800   Warning: >
801     A slightly different error
802     message.
803   ---
804   Date: 2001-11-23 15:03:17 -05:00
805   User: ed
806   Fatal: >
807     Unknown variable "bar"
808   Stack:
809     - file: TopClass.py
810       line: 23
811       code: |
812         x = MoreObject("345\n")
813     - file: MoreClass.py
814       line: 58
815       code: |-
816         foo = bar
817 ruby: |
818   y = YAML::Stream.new
819   y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ),
820            'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } )
821   y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ),
822            'User' => 'ed', 'Warning' => "A slightly different error message.\n" } )
823   y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ),
824            'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n",
825            'Stack' => [
826            { 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" },
827            { 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } )
828 documents: 3
829
830 ---
831 test: Throwaway comments
832 yaml: |
833    ### These are four throwaway comment  ###
834
835    ### lines (the second line is empty). ###
836    this: |   # Comments may trail lines.
837       contains three lines of text.
838       The third one starts with a
839       # character. This isn't a comment.
840
841    # These are three throwaway comment
842    # lines (the first line is empty).
843 php: |
844    array(
845      'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
846    )
847 ---
848 test: Document with a single value
849 todo: true
850 yaml: |
851    --- >
852    This YAML stream contains a single text value.
853    The next stream is a log file - a sequence of
854    log entries. Adding an entry to the log is a
855    simple matter of appending it at the end.
856 ruby: |
857    "This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end.\n"
858 ---
859 test: Document stream
860 todo: true
861 yaml: |
862    ---
863    at: 2001-08-12 09:25:00.00 Z
864    type: GET
865    HTTP: '1.0'
866    url: '/index.html'
867    ---
868    at: 2001-08-12 09:25:10.00 Z
869    type: GET
870    HTTP: '1.0'
871    url: '/toc.html'
872 ruby: |
873    y = YAML::Stream.new
874    y.add( {
875       'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ),
876       'type' => 'GET',
877       'HTTP' => '1.0',
878       'url' => '/index.html'
879    } )
880    y.add( {
881       'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ),
882       'type' => 'GET',
883       'HTTP' => '1.0',
884       'url' => '/toc.html'
885    } )
886 documents: 2
887
888 ---
889 test: Top level mapping
890 yaml: |
891    # This stream is an example of a top-level mapping.
892    invoice : 34843
893    date    : 2001-01-23
894    total   : 4443.52
895 php: |
896    array(
897       'invoice' => 34843,
898       'date' => gmmktime(0, 0, 0, 1, 23, 2001),
899       'total' => 4443.52
900    )
901 ---
902 test: Single-line documents
903 todo: true
904 yaml: |
905   # The following is a sequence of three documents.
906   # The first contains an empty mapping, the second
907   # an empty sequence, and the last an empty string.
908   --- {}
909   --- [ ]
910   --- ''
911 ruby: |
912   y = YAML::Stream.new
913   y.add( {} )
914   y.add( [] )
915   y.add( '' )
916 documents: 3
917
918 ---
919 test: Document with pause
920 todo: true
921 yaml: |
922   # A communication channel based on a YAML stream.
923   ---
924   sent at: 2002-06-06 11:46:25.10 Z
925   payload: Whatever
926   # Receiver can process this as soon as the following is sent:
927   ...
928   # Even if the next message is sent long after:
929   ---
930   sent at: 2002-06-06 12:05:53.47 Z
931   payload: Whatever
932   ...
933 ruby: |
934   y = YAML::Stream.new
935   y.add(
936     { 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ),
937       'payload' => 'Whatever' }
938   )
939   y.add(
940     { "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) }
941   )
942 documents: 2
943
944 ---
945 test: Explicit typing
946 yaml: |
947    integer: 12
948    also int: ! "12"
949    string: !str 12
950 php: |
951    array( 'integer' => 12, 'also int' => 12, 'string' => '12' )
952 ---
953 test: Private types
954 todo: true
955 yaml: |
956   # Both examples below make use of the 'x-private:ball'
957   # type family URI, but with different semantics.
958   ---
959   pool: !!ball
960     number: 8
961     color: black
962   ---
963   bearing: !!ball
964     material: steel
965 ruby: |
966   y = YAML::Stream.new
967   y.add( { 'pool' =>
968     YAML::PrivateType.new( 'ball',
969       { 'number' => 8, 'color' => 'black' } ) }
970   )
971   y.add( { 'bearing' =>
972     YAML::PrivateType.new( 'ball',
973       { 'material' => 'steel' } ) }
974   )
975 documents: 2
976
977 ---
978 test: Type family under yaml.org
979 yaml: |
980   # The URI is 'tag:yaml.org,2002:str'
981   - !str a Unicode string
982 php: |
983   array( 'a Unicode string' )
984 ---
985 test: Type family under perl.yaml.org
986 todo: true
987 yaml: |
988   # The URI is 'tag:perl.yaml.org,2002:Text::Tabs'
989   - !perl/Text::Tabs {}
990 ruby: |
991   [ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ]
992 ---
993 test: Type family under clarkevans.com
994 todo: true
995 yaml: |
996   # The URI is 'tag:clarkevans.com,2003-02:timesheet'
997   - !clarkevans.com,2003-02/timesheet {}
998 ruby: |
999   [ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ]
1000 ---
1001 test: URI Escaping
1002 todo: true
1003 yaml: |
1004   same:
1005     - !domain.tld,2002/type\x30 value
1006     - !domain.tld,2002/type0 value
1007   different: # As far as the YAML parser is concerned
1008     - !domain.tld,2002/type%30 value
1009     - !domain.tld,2002/type0 value
1010 ruby-setup: |
1011   YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
1012     "ONE: #{val}"
1013   }
1014   YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
1015     "TWO: #{val}"
1016   }
1017 ruby: |
1018   { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] }
1019 ---
1020 test: URI Prefixing
1021 todo: true
1022 yaml: |
1023   # 'tag:domain.tld,2002:invoice' is some type family.
1024   invoice: !domain.tld,2002/^invoice
1025     # 'seq' is shorthand for 'tag:yaml.org,2002:seq'.
1026     # This does not effect '^customer' below
1027     # because it is does not specify a prefix.
1028     customers: !seq
1029       # '^customer' is shorthand for the full
1030       # notation 'tag:domain.tld,2002:customer'.
1031       - !^customer
1032         given : Chris
1033         family : Dumars
1034 ruby-setup: |
1035   YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val|
1036     if val.is_a? ::Hash
1037       scheme, domain, type = type.split( /:/, 3 )
1038       val['type'] = "domain #{type}"
1039       val
1040     else
1041       raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect
1042     end
1043   }
1044 ruby: |
1045   { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }
1046
1047 ---
1048 test: Overriding anchors
1049 yaml: |
1050   anchor : &A001 This scalar has an anchor.
1051   override : &A001 >
1052    The alias node below is a
1053    repeated use of this value.
1054   alias : *A001
1055 php: |
1056   array( 'anchor' => 'This scalar has an anchor.',
1057     'override' => "The alias node below is a repeated use of this value.\n",
1058     'alias' => "The alias node below is a repeated use of this value.\n" )
1059 ---
1060 test: Flow and block formatting
1061 todo: true
1062 yaml: |
1063   empty: []
1064   flow: [ one, two, three # May span lines,
1065            , four,           # indentation is
1066              five ]          # mostly ignored.
1067   block:
1068    - First item in top sequence
1069    -
1070     - Subordinate sequence entry
1071    - >
1072      A folded sequence entry
1073    - Sixth item in top sequence
1074 ruby: |
1075   { 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ],
1076     'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ],
1077     "A folded sequence entry\n", 'Sixth item in top sequence' ] }
1078 ---
1079 test: Complete mapping test
1080 todo: true
1081 yaml: |
1082  empty: {}
1083  flow: { one: 1, two: 2 }
1084  spanning: { one: 1,
1085     two: 2 }
1086  block:
1087   first : First entry
1088   second:
1089    key: Subordinate mapping
1090   third:
1091    - Subordinate sequence
1092    - { }
1093    - Previous mapping is empty.
1094    - A key: value pair in a sequence.
1095      A second: key:value pair.
1096    - The previous entry is equal to the following one.
1097    -
1098      A key: value pair in a sequence.
1099      A second: key:value pair.
1100   !float 12 : This key is a float.
1101   ? >
1102    ?
1103   : This key had to be protected.
1104   "\a" : This key had to be escaped.
1105   ? >
1106    This is a
1107    multi-line
1108    folded key
1109   : Whose value is
1110     also multi-line.
1111   ? this also works as a key
1112   : with a value at the next line.
1113   ?
1114    - This key
1115    - is a sequence
1116   :
1117    - With a sequence value.
1118   ?
1119    This: key
1120    is a: mapping
1121   :
1122    with a: mapping value.
1123 ruby: |
1124   { 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 },
1125     'spanning' => { 'one' => 1, 'two' => 2 },
1126     'block' => { 'first' => 'First entry', 'second' =>
1127     { 'key' => 'Subordinate mapping' }, 'third' =>
1128       [ 'Subordinate sequence', {}, 'Previous mapping is empty.',
1129         { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' },
1130         'The previous entry is equal to the following one.',
1131         { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ],
1132     12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.',
1133     "\a" => 'This key had to be escaped.',
1134     "This is a multi-line folded key\n" => "Whose value is also multi-line.",
1135     'this also works as a key' => 'with a value at the next line.',
1136     [ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } }
1137   # Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact
1138   obj_y['block'].keys.each { |k|
1139     if Hash === k
1140       v = obj_y['block'][k]
1141       if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.'
1142          obj_r['block'][k] = v
1143       end
1144     end
1145   }
1146 ---
1147 test: Literal explicit indentation
1148 yaml: |
1149    # Explicit indentation must
1150    # be given in all the three
1151    # following cases.
1152    leading spaces: |2
1153          This value starts with four spaces.
1154
1155    leading line break: |2
1156
1157      This value starts with a line break.
1158
1159    leading comment indicator: |2
1160      # first line starts with a
1161      # character.
1162
1163    # Explicit indentation may
1164    # also be given when it is
1165    # not required.
1166    redundant: |2
1167      This value is indented 2 spaces.
1168 php: |
1169    array(
1170       'leading spaces' => "    This value starts with four spaces.\n",
1171       'leading line break' => "\nThis value starts with a line break.\n",
1172       'leading comment indicator' => "# first line starts with a\n# character.\n",
1173       'redundant' => "This value is indented 2 spaces.\n"
1174    )
1175 ---
1176 test: Chomping and keep modifiers
1177 yaml: |
1178     clipped: |
1179         This has one newline.
1180
1181     same as "clipped" above: "This has one newline.\n"
1182
1183     stripped: |-
1184         This has no newline.
1185
1186     same as "stripped" above: "This has no newline."
1187
1188     kept: |+
1189         This has two newlines.
1190
1191     same as "kept" above: "This has two newlines.\n\n"
1192 php: |
1193     array(
1194       'clipped' => "This has one newline.\n",
1195       'same as "clipped" above' => "This has one newline.\n",
1196       'stripped' => 'This has no newline.',
1197       'same as "stripped" above' => 'This has no newline.',
1198       'kept' => "This has two newlines.\n\n",
1199       'same as "kept" above' => "This has two newlines.\n\n"
1200     )
1201 ---
1202 test: Literal combinations
1203 todo: true
1204 yaml: |
1205    empty: |
1206
1207    literal: |
1208     The \ ' " characters may be
1209     freely used. Leading white
1210        space is significant.
1211
1212     Line breaks are significant.
1213     Thus this value contains one
1214     empty line and ends with a
1215     single line break, but does
1216     not start with one.
1217
1218    is equal to: "The \\ ' \" characters may \
1219     be\nfreely used. Leading white\n   space \
1220     is significant.\n\nLine breaks are \
1221     significant.\nThus this value contains \
1222     one\nempty line and ends with a\nsingle \
1223     line break, but does\nnot start with one.\n"
1224
1225    # Comments may follow a block
1226    # scalar value. They must be
1227    # less indented.
1228
1229    # Modifiers may be combined in any order.
1230    indented and chomped: |2-
1231        This has no newline.
1232
1233    also written as: |-2
1234        This has no newline.
1235
1236    both are equal to: "  This has no newline."
1237 php: |
1238    array(
1239      'empty' => '',
1240      'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n   space " +
1241        "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
1242        "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
1243      'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n   space " +
1244        "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
1245        "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
1246      'indented and chomped' => '  This has no newline.',
1247      'also written as' => '  This has no newline.',
1248      'both are equal to' => '  This has no newline.'
1249    )
1250 ---
1251 test: Folded combinations
1252 todo: true
1253 yaml: |
1254    empty: >
1255
1256    one paragraph: >
1257     Line feeds are converted
1258     to spaces, so this value
1259     contains no line breaks
1260     except for the final one.
1261
1262    multiple paragraphs: >2
1263
1264      An empty line, either
1265      at the start or in
1266      the value:
1267
1268      Is interpreted as a
1269      line break. Thus this
1270      value contains three
1271      line breaks.
1272
1273    indented text: >
1274        This is a folded
1275        paragraph followed
1276        by a list:
1277         * first entry
1278         * second entry
1279        Followed by another
1280        folded paragraph,
1281        another list:
1282
1283         * first entry
1284
1285         * second entry
1286
1287        And a final folded
1288        paragraph.
1289
1290    above is equal to: |
1291        This is a folded paragraph followed by a list:
1292         * first entry
1293         * second entry
1294        Followed by another folded paragraph, another list:
1295
1296         * first entry
1297
1298         * second entry
1299
1300        And a final folded paragraph.
1301
1302    # Explicit comments may follow
1303    # but must be less indented.
1304 php: |
1305    array(
1306      'empty' => '',
1307      'one paragraph' => 'Line feeds are converted to spaces, so this value'.
1308        " contains no line breaks except for the final one.\n",
1309      'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n".
1310        "Is interpreted as a line break. Thus this value contains three line breaks.\n",
1311      'indented text' => "This is a folded paragraph followed by a list:\n".
1312        " * first entry\n * second entry\nFollowed by another folded paragraph, ".
1313        "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n",
1314      'above is equal to' => "This is a folded paragraph followed by a list:\n".
1315        " * first entry\n * second entry\nFollowed by another folded paragraph, ".
1316        "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
1317    )
1318 ---
1319 test: Single quotes
1320 todo: true
1321 yaml: |
1322    empty: ''
1323    second: '! : \ etc. can be used freely.'
1324    third: 'a single quote '' must be escaped.'
1325    span: 'this contains
1326          six spaces
1327
1328          and one
1329          line break'
1330    is same as: "this contains six spaces\nand one line break"
1331 php: |
1332    array(
1333      'empty' => '',
1334      'second' => '! : \\ etc. can be used freely.',
1335      'third' => "a single quote ' must be escaped.",
1336      'span' => "this contains six spaces\nand one line break",
1337      'is same as' => "this contains six spaces\nand one line break"
1338    )
1339 ---
1340 test: Double quotes
1341 todo: true
1342 yaml: |
1343    empty: ""
1344    second: "! : etc. can be used freely."
1345    third: "a \" or a \\ must be escaped."
1346    fourth: "this value ends with an LF.\n"
1347    span: "this contains
1348      four  \
1349          spaces"
1350    is equal to: "this contains four  spaces"
1351 php: |
1352    array(
1353      'empty' => '',
1354      'second' => '! : etc. can be used freely.',
1355      'third' => 'a " or a \\ must be escaped.',
1356      'fourth' => "this value ends with an LF.\n",
1357      'span' => "this contains four  spaces",
1358      'is equal to' => "this contains four  spaces"
1359    )
1360 ---
1361 test: Unquoted strings
1362 todo: true
1363 yaml: |
1364    first: There is no unquoted empty string.
1365
1366    second: 12          ## This is an integer.
1367
1368    third: !str 12      ## This is a string.
1369
1370    span: this contains
1371          six spaces
1372
1373          and one
1374          line break
1375
1376    indicators: this has no comments.
1377                #:foo and bar# are
1378                both text.
1379
1380    flow: [ can span
1381               lines, # comment
1382               like
1383               this ]
1384
1385    note: { one-line keys: but multi-line values }
1386
1387 php: |
1388    array(
1389      'first' => 'There is no unquoted empty string.',
1390      'second' => 12,
1391      'third' => '12',
1392      'span' => "this contains six spaces\nand one line break",
1393      'indicators' => "this has no comments. #:foo and bar# are both text.",
1394      'flow' => [ 'can span lines', 'like this' ],
1395      'note' => { 'one-line keys' => 'but multi-line values' }
1396    )
1397 ---
1398 test: Spanning sequences
1399 todo: true
1400 yaml: |
1401    # The following are equal seqs
1402    # with different identities.
1403    flow: [ one, two ]
1404    spanning: [ one,
1405         two ]
1406    block:
1407      - one
1408      - two
1409 php: |
1410    array(
1411      'flow' => [ 'one', 'two' ],
1412      'spanning' => [ 'one', 'two' ],
1413      'block' => [ 'one', 'two' ]
1414    )
1415 ---
1416 test: Flow mappings
1417 yaml: |
1418    # The following are equal maps
1419    # with different identities.
1420    flow: { one: 1, two: 2 }
1421    block:
1422        one: 1
1423        two: 2
1424 php: |
1425    array(
1426      'flow' => array( 'one' => 1, 'two' => 2 ),
1427      'block' => array( 'one' => 1, 'two' => 2 )
1428    )
1429 ---
1430 test: Representations of 12
1431 todo: true
1432 yaml: |
1433    - 12 # An integer
1434    # The following scalars
1435    # are loaded to the
1436    # string value '1' '2'.
1437    - !str 12
1438    - '12'
1439    - "12"
1440    - "\
1441      1\
1442      2\
1443      "
1444    # Strings containing paths and regexps can be unquoted:
1445    - /foo/bar
1446    - d:/foo/bar
1447    - foo/bar
1448    - /a.*b/
1449 php: |
1450    array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' )
1451 ---
1452 test: "Null"
1453 todo: true
1454 yaml: |
1455    canonical: ~
1456
1457    english: null
1458
1459    # This sequence has five
1460    # entries, two with values.
1461    sparse:
1462      - ~
1463      - 2nd entry
1464      - Null
1465      - 4th entry
1466      -
1467
1468    four: This mapping has five keys,
1469          only two with values.
1470
1471 php: |
1472    array (
1473      'canonical' => null,
1474      'english' => null,
1475      'sparse' => array( null, '2nd entry', null, '4th entry', null ]),
1476      'four' => 'This mapping has five keys, only two with values.'
1477    )
1478 ---
1479 test: Omap
1480 todo: true
1481 yaml: |
1482    # Explicitly typed dictionary.
1483    Bestiary: !omap
1484      - aardvark: African pig-like ant eater. Ugly.
1485      - anteater: South-American ant eater. Two species.
1486      - anaconda: South-American constrictor snake. Scary.
1487      # Etc.
1488 ruby: |
1489    {
1490      'Bestiary' => YAML::Omap[
1491        'aardvark', 'African pig-like ant eater. Ugly.',
1492        'anteater', 'South-American ant eater. Two species.',
1493        'anaconda', 'South-American constrictor snake. Scary.'
1494      ]
1495    }
1496
1497 ---
1498 test: Pairs
1499 todo: true
1500 yaml: |
1501   # Explicitly typed pairs.
1502   tasks: !pairs
1503     - meeting: with team.
1504     - meeting: with boss.
1505     - break: lunch.
1506     - meeting: with client.
1507 ruby: |
1508   {
1509     'tasks' => YAML::Pairs[
1510       'meeting', 'with team.',
1511       'meeting', 'with boss.',
1512       'break', 'lunch.',
1513       'meeting', 'with client.'
1514     ]
1515   }
1516
1517 ---
1518 test: Set
1519 todo: true
1520 yaml: |
1521   # Explicitly typed set.
1522   baseball players: !set
1523     Mark McGwire:
1524     Sammy Sosa:
1525     Ken Griffey:
1526 ruby: |
1527   {
1528     'baseball players' => YAML::Set[
1529       'Mark McGwire', nil,
1530       'Sammy Sosa', nil,
1531       'Ken Griffey', nil
1532     ]
1533   }
1534
1535 ---
1536 test: Boolean
1537 yaml: |
1538    false: used as key
1539    logical:  true
1540    answer: false
1541 php: |
1542    array(
1543      false => 'used as key',
1544      'logical' => true,
1545      'answer' => false
1546    )
1547 ---
1548 test: Integer
1549 yaml: |
1550    canonical: 12345
1551    octal: 014
1552    hexadecimal: 0xC
1553 php: |
1554    array(
1555      'canonical' => 12345,
1556      'octal' => 12,
1557      'hexadecimal' => 12
1558    )
1559 ---
1560 test: Decimal
1561 deprecated: true
1562 yaml: |
1563    decimal: +12,345
1564 php: |
1565    array(
1566      'decimal' => 12345.0,
1567    )
1568 ---
1569 test: Fixed Float
1570 deprecated: true
1571 yaml: |
1572    fixed: 1,230.15
1573 php: |
1574   array(
1575     'fixed' => 1230.15,
1576   )
1577 ---
1578 test: Float
1579 yaml: |
1580    canonical: 1.23015e+3
1581    exponential: 12.3015e+02
1582    negative infinity: -.inf
1583    not a number: .NaN
1584 php: |
1585   array(
1586     'canonical' => 1230.15,
1587     'exponential' => 1230.15,
1588     'negative infinity' => log(0),
1589     'not a number' => -log(0)
1590   )
1591 ---
1592 test: Timestamp
1593 todo: true
1594 yaml: |
1595    canonical:       2001-12-15T02:59:43.1Z
1596    valid iso8601:   2001-12-14t21:59:43.10-05:00
1597    space separated: 2001-12-14 21:59:43.10 -05:00
1598    date (noon UTC): 2002-12-14
1599 ruby: |
1600    array(
1601      'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
1602      'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
1603      'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
1604      'date (noon UTC)' => Date.new( 2002, 12, 14 )
1605    )
1606 ---
1607 test: Binary
1608 todo: true
1609 yaml: |
1610    canonical: !binary "\
1611     R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
1612     OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
1613     +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
1614     AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
1615    base64: !binary |
1616     R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
1617     OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
1618     +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
1619     AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
1620    description: >
1621     The binary value above is a tiny arrow
1622     encoded as a gif image.
1623 ruby-setup: |
1624    arrow_gif = "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236iiiccc\243\243\243\204\204\204\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371!\376\016Made with GIMP\000,\000\000\000\000\f\000\f\000\000\005,  \216\2010\236\343@\024\350i\020\304\321\212\010\034\317\200M$z\357\3770\205p\270\2601f\r\e\316\001\303\001\036\020' \202\n\001\000;"
1625 ruby: |
1626    {
1627      'canonical' => arrow_gif,
1628      'base64' => arrow_gif,
1629      'description' => "The binary value above is a tiny arrow encoded as a gif image.\n"
1630    }
1631
1632 ---
1633 test: Merge key
1634 todo: true
1635 yaml: |
1636   ---
1637   - &CENTER { x: 1, y: 2 }
1638   - &LEFT { x: 0, y: 2 }
1639   - &BIG { r: 10 }
1640   - &SMALL { r: 1 }
1641
1642   # All the following maps are equal:
1643
1644   - # Explicit keys
1645     x: 1
1646     y: 2
1647     r: 10
1648     label: center/big
1649
1650   - # Merge one map
1651     << : *CENTER
1652     r: 10
1653     label: center/big
1654
1655   - # Merge multiple maps
1656     << : [ *CENTER, *BIG ]
1657     label: center/big
1658
1659   - # Override
1660     << : [ *BIG, *LEFT, *SMALL ]
1661     x: 1
1662     label: center/big
1663
1664 ruby-setup: |
1665   center = { 'x' => 1, 'y' => 2 }
1666   left = { 'x' => 0, 'y' => 2 }
1667   big = { 'r' => 10 }
1668   small = { 'r' => 1 }
1669   node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' }
1670   node2 = center.dup
1671   node2.update( { 'r' => 10, 'label' => 'center/big' } )
1672   node3 = big.dup
1673   node3.update( center )
1674   node3.update( { 'label' => 'center/big' } )
1675   node4 = small.dup
1676   node4.update( left )
1677   node4.update( big )
1678   node4.update( { 'x' => 1, 'label' => 'center/big' } )
1679
1680 ruby: |
1681   [
1682     center, left, big, small, node1, node2, node3, node4
1683   ]
1684
1685 ---
1686 test: Default key
1687 todo: true
1688 yaml: |
1689    ---     # Old schema
1690    link with:
1691      - library1.dll
1692      - library2.dll
1693    ---     # New schema
1694    link with:
1695      - = : library1.dll
1696        version: 1.2
1697      - = : library2.dll
1698        version: 2.3
1699 ruby: |
1700    y = YAML::Stream.new
1701    y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } )
1702    obj_h = Hash[ 'version' => 1.2 ]
1703    obj_h.default = 'library1.dll'
1704    obj_h2 = Hash[ 'version' => 2.3 ]
1705    obj_h2.default = 'library2.dll'
1706    y.add( { 'link with' => [ obj_h, obj_h2 ] } )
1707 documents: 2
1708
1709 ---
1710 test: Special keys
1711 todo: true
1712 yaml: |
1713    "!": These three keys
1714    "&": had to be quoted
1715    "=": and are normal strings.
1716    # NOTE: the following node should NOT be serialized this way.
1717    encoded node :
1718     !special '!' : '!type'
1719     !special|canonical '&' : 12
1720     = : value
1721    # The proper way to serialize the above node is as follows:
1722    node : !!type &12 value
1723 ruby: |
1724    { '!' => 'These three keys', '&' => 'had to be quoted',
1725      '=' => 'and are normal strings.',
1726      'encoded node' => YAML::PrivateType.new( 'type', 'value' ),
1727      'node' => YAML::PrivateType.new( 'type', 'value' ) }