mkrf 0.1.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.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
|
@@ -0,0 +1,2699 @@
|
|
|
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
|
+
perl: |
|
|
9
|
+
[ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
|
|
10
|
+
python: |
|
|
11
|
+
[ ['Mark McGwire', 'Sammy Sosa', 'Ken Griffey'] ]
|
|
12
|
+
ruby: |
|
|
13
|
+
[ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
|
|
14
|
+
syck: |
|
|
15
|
+
struct test_node seq[] = {
|
|
16
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
17
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
18
|
+
{ T_STR, 0, "Ken Griffey" },
|
|
19
|
+
end_node
|
|
20
|
+
};
|
|
21
|
+
struct test_node stream[] = {
|
|
22
|
+
{ T_SEQ, 0, 0, seq },
|
|
23
|
+
end_node
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
test: Mapping of scalars to scalars
|
|
28
|
+
spec: 2.2
|
|
29
|
+
yaml: |
|
|
30
|
+
hr: 65
|
|
31
|
+
avg: 0.278
|
|
32
|
+
rbi: 147
|
|
33
|
+
perl: |
|
|
34
|
+
{ hr => 65, avg => 0.278, rbi => 147 }
|
|
35
|
+
python: |
|
|
36
|
+
[ {'hr': 65, 'avg': .278, 'rbi': 147} ]
|
|
37
|
+
ruby: |
|
|
38
|
+
{ 'hr' => 65, 'avg' => 0.278, 'rbi' => 147 }
|
|
39
|
+
syck: |
|
|
40
|
+
struct test_node map[] = {
|
|
41
|
+
{ T_STR, 0, "hr" },
|
|
42
|
+
{ T_STR, 0, "65" },
|
|
43
|
+
{ T_STR, 0, "avg" },
|
|
44
|
+
{ T_STR, 0, "0.278" },
|
|
45
|
+
{ T_STR, 0, "rbi" },
|
|
46
|
+
{ T_STR, 0, "147" },
|
|
47
|
+
end_node
|
|
48
|
+
};
|
|
49
|
+
struct test_node stream[] = {
|
|
50
|
+
{ T_MAP, 0, 0, map },
|
|
51
|
+
end_node
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
test: Mapping of scalars to sequences
|
|
56
|
+
spec: 2.3
|
|
57
|
+
yaml: |
|
|
58
|
+
american:
|
|
59
|
+
- Boston Red Sox
|
|
60
|
+
- Detroit Tigers
|
|
61
|
+
- New York Yankees
|
|
62
|
+
national:
|
|
63
|
+
- New York Mets
|
|
64
|
+
- Chicago Cubs
|
|
65
|
+
- Atlanta Braves
|
|
66
|
+
perl: |
|
|
67
|
+
{ american =>
|
|
68
|
+
[ 'Boston Red Sox', 'Detroit Tigers',
|
|
69
|
+
'New York Yankees' ],
|
|
70
|
+
national =>
|
|
71
|
+
[ 'New York Mets', 'Chicago Cubs',
|
|
72
|
+
'Atlanta Braves' ]
|
|
73
|
+
}
|
|
74
|
+
python: |
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
'american':
|
|
78
|
+
['Boston Red Sox', 'Detroit Tigers',
|
|
79
|
+
'New York Yankees'],
|
|
80
|
+
'national':
|
|
81
|
+
['New York Mets', 'Chicago Cubs',
|
|
82
|
+
'Atlanta Braves']
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
ruby: |
|
|
86
|
+
{ 'american' =>
|
|
87
|
+
[ 'Boston Red Sox', 'Detroit Tigers',
|
|
88
|
+
'New York Yankees' ],
|
|
89
|
+
'national' =>
|
|
90
|
+
[ 'New York Mets', 'Chicago Cubs',
|
|
91
|
+
'Atlanta Braves' ]
|
|
92
|
+
}
|
|
93
|
+
syck: |
|
|
94
|
+
struct test_node seq1[] = {
|
|
95
|
+
{ T_STR, 0, "Boston Red Sox" },
|
|
96
|
+
{ T_STR, 0, "Detroit Tigers" },
|
|
97
|
+
{ T_STR, 0, "New York Yankees" },
|
|
98
|
+
end_node
|
|
99
|
+
};
|
|
100
|
+
struct test_node seq2[] = {
|
|
101
|
+
{ T_STR, 0, "New York Mets" },
|
|
102
|
+
{ T_STR, 0, "Chicago Cubs" },
|
|
103
|
+
{ T_STR, 0, "Atlanta Braves" },
|
|
104
|
+
end_node
|
|
105
|
+
};
|
|
106
|
+
struct test_node map[] = {
|
|
107
|
+
{ T_STR, 0, "american" },
|
|
108
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
109
|
+
{ T_STR, 0, "national" },
|
|
110
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
111
|
+
end_node
|
|
112
|
+
};
|
|
113
|
+
struct test_node stream[] = {
|
|
114
|
+
{ T_MAP, 0, 0, map },
|
|
115
|
+
end_node
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
test: Sequence of mappings
|
|
120
|
+
spec: 2.4
|
|
121
|
+
yaml: |
|
|
122
|
+
-
|
|
123
|
+
name: Mark McGwire
|
|
124
|
+
hr: 65
|
|
125
|
+
avg: 0.278
|
|
126
|
+
-
|
|
127
|
+
name: Sammy Sosa
|
|
128
|
+
hr: 63
|
|
129
|
+
avg: 0.288
|
|
130
|
+
perl: |
|
|
131
|
+
[
|
|
132
|
+
{name => 'Mark McGwire', hr => 65, avg => 0.278},
|
|
133
|
+
{name => 'Sammy Sosa', hr => 63, avg => 0.288}
|
|
134
|
+
]
|
|
135
|
+
python: |
|
|
136
|
+
[[
|
|
137
|
+
{
|
|
138
|
+
'name': 'Mark McGwire',
|
|
139
|
+
'hr': 65,
|
|
140
|
+
'avg': 0.278
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
'name': 'Sammy Sosa',
|
|
144
|
+
'hr': 63,
|
|
145
|
+
'avg': 0.288
|
|
146
|
+
}
|
|
147
|
+
]]
|
|
148
|
+
ruby: |
|
|
149
|
+
[
|
|
150
|
+
{'name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278},
|
|
151
|
+
{'name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288}
|
|
152
|
+
]
|
|
153
|
+
syck: |
|
|
154
|
+
struct test_node map1[] = {
|
|
155
|
+
{ T_STR, 0, "name" },
|
|
156
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
157
|
+
{ T_STR, 0, "hr" },
|
|
158
|
+
{ T_STR, 0, "65" },
|
|
159
|
+
{ T_STR, 0, "avg" },
|
|
160
|
+
{ T_STR, 0, "0.278" },
|
|
161
|
+
end_node
|
|
162
|
+
};
|
|
163
|
+
struct test_node map2[] = {
|
|
164
|
+
{ T_STR, 0, "name" },
|
|
165
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
166
|
+
{ T_STR, 0, "hr" },
|
|
167
|
+
{ T_STR, 0, "63" },
|
|
168
|
+
{ T_STR, 0, "avg" },
|
|
169
|
+
{ T_STR, 0, "0.288" },
|
|
170
|
+
end_node
|
|
171
|
+
};
|
|
172
|
+
struct test_node seq[] = {
|
|
173
|
+
{ T_MAP, 0, 0, map1 },
|
|
174
|
+
{ T_MAP, 0, 0, map2 },
|
|
175
|
+
end_node
|
|
176
|
+
};
|
|
177
|
+
struct test_node stream[] = {
|
|
178
|
+
{ T_SEQ, 0, 0, seq },
|
|
179
|
+
end_node
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
test: Legacy A5
|
|
184
|
+
spec: legacy_A5
|
|
185
|
+
yaml: |
|
|
186
|
+
?
|
|
187
|
+
- New York Yankees
|
|
188
|
+
- Atlanta Braves
|
|
189
|
+
:
|
|
190
|
+
- 2001-07-02
|
|
191
|
+
- 2001-08-12
|
|
192
|
+
- 2001-08-14
|
|
193
|
+
?
|
|
194
|
+
- Detroit Tigers
|
|
195
|
+
- Chicago Cubs
|
|
196
|
+
:
|
|
197
|
+
- 2001-07-23
|
|
198
|
+
perl-busted: >
|
|
199
|
+
YAML.pm will be able to emulate this behavior soon. In this regard
|
|
200
|
+
it may be somewhat more correct than Python's native behaviour which
|
|
201
|
+
can only use tuples as mapping keys. PyYAML will also need to figure
|
|
202
|
+
out some clever way to roundtrip structured keys.
|
|
203
|
+
python: |
|
|
204
|
+
[
|
|
205
|
+
{
|
|
206
|
+
('New York Yankees', 'Atlanta Braves'):
|
|
207
|
+
[yaml.timestamp('2001-07-02'),
|
|
208
|
+
yaml.timestamp('2001-08-12'),
|
|
209
|
+
yaml.timestamp('2001-08-14')],
|
|
210
|
+
('Detroit Tigers', 'Chicago Cubs'):
|
|
211
|
+
[yaml.timestamp('2001-07-23')]
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
ruby: |
|
|
215
|
+
{
|
|
216
|
+
[ 'New York Yankees', 'Atlanta Braves' ] =>
|
|
217
|
+
[ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ],
|
|
218
|
+
[ 'Detroit Tigers', 'Chicago Cubs' ] =>
|
|
219
|
+
[ Date.new( 2001, 7, 23 ) ]
|
|
220
|
+
}
|
|
221
|
+
syck: |
|
|
222
|
+
struct test_node seq1[] = {
|
|
223
|
+
{ T_STR, 0, "New York Yankees" },
|
|
224
|
+
{ T_STR, 0, "Atlanta Braves" },
|
|
225
|
+
end_node
|
|
226
|
+
};
|
|
227
|
+
struct test_node seq2[] = {
|
|
228
|
+
{ T_STR, 0, "2001-07-02" },
|
|
229
|
+
{ T_STR, 0, "2001-08-12" },
|
|
230
|
+
{ T_STR, 0, "2001-08-14" },
|
|
231
|
+
end_node
|
|
232
|
+
};
|
|
233
|
+
struct test_node seq3[] = {
|
|
234
|
+
{ T_STR, 0, "Detroit Tigers" },
|
|
235
|
+
{ T_STR, 0, "Chicago Cubs" },
|
|
236
|
+
end_node
|
|
237
|
+
};
|
|
238
|
+
struct test_node seq4[] = {
|
|
239
|
+
{ T_STR, 0, "2001-07-23" },
|
|
240
|
+
end_node
|
|
241
|
+
};
|
|
242
|
+
struct test_node map[] = {
|
|
243
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
244
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
245
|
+
{ T_SEQ, 0, 0, seq3 },
|
|
246
|
+
{ T_SEQ, 0, 0, seq4 },
|
|
247
|
+
end_node
|
|
248
|
+
};
|
|
249
|
+
struct test_node stream[] = {
|
|
250
|
+
{ T_MAP, 0, 0, map },
|
|
251
|
+
end_node
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
test: Sequence of sequences
|
|
256
|
+
spec: 2.5
|
|
257
|
+
yaml: |
|
|
258
|
+
- [ name , hr , avg ]
|
|
259
|
+
- [ Mark McGwire , 65 , 0.278 ]
|
|
260
|
+
- [ Sammy Sosa , 63 , 0.288 ]
|
|
261
|
+
perl: |
|
|
262
|
+
[
|
|
263
|
+
[ 'name', 'hr', 'avg' ],
|
|
264
|
+
[ 'Mark McGwire', 65, 0.278 ],
|
|
265
|
+
[ 'Sammy Sosa', 63, 0.288 ],
|
|
266
|
+
]
|
|
267
|
+
python: |
|
|
268
|
+
[[
|
|
269
|
+
[ 'name', 'hr', 'avg' ],
|
|
270
|
+
[ 'Mark McGwire', 65, 0.278 ],
|
|
271
|
+
[ 'Sammy Sosa', 63, 0.288 ]
|
|
272
|
+
]]
|
|
273
|
+
ruby: |
|
|
274
|
+
[
|
|
275
|
+
[ 'name', 'hr', 'avg' ],
|
|
276
|
+
[ 'Mark McGwire', 65, 0.278 ],
|
|
277
|
+
[ 'Sammy Sosa', 63, 0.288 ]
|
|
278
|
+
]
|
|
279
|
+
syck: |
|
|
280
|
+
struct test_node seq1[] = {
|
|
281
|
+
{ T_STR, 0, "name" },
|
|
282
|
+
{ T_STR, 0, "hr" },
|
|
283
|
+
{ T_STR, 0, "avg" },
|
|
284
|
+
end_node
|
|
285
|
+
};
|
|
286
|
+
struct test_node seq2[] = {
|
|
287
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
288
|
+
{ T_STR, 0, "65" },
|
|
289
|
+
{ T_STR, 0, "0.278" },
|
|
290
|
+
end_node
|
|
291
|
+
};
|
|
292
|
+
struct test_node seq3[] = {
|
|
293
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
294
|
+
{ T_STR, 0, "63" },
|
|
295
|
+
{ T_STR, 0, "0.288" },
|
|
296
|
+
end_node
|
|
297
|
+
};
|
|
298
|
+
struct test_node seq[] = {
|
|
299
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
300
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
301
|
+
{ T_SEQ, 0, 0, seq3 },
|
|
302
|
+
end_node
|
|
303
|
+
};
|
|
304
|
+
struct test_node stream[] = {
|
|
305
|
+
{ T_SEQ, 0, 0, seq },
|
|
306
|
+
end_node
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
test: Mapping of mappings
|
|
311
|
+
spec: 2.6
|
|
312
|
+
yaml: |
|
|
313
|
+
Mark McGwire: {hr: 65, avg: 0.278}
|
|
314
|
+
Sammy Sosa: {
|
|
315
|
+
hr: 63,
|
|
316
|
+
avg: 0.288
|
|
317
|
+
}
|
|
318
|
+
perl-xxx: |
|
|
319
|
+
{
|
|
320
|
+
'Mark McGwire' => { 'hr' => 65, 'avg' => 0.278 },
|
|
321
|
+
'Sammy Sosa' => { 'hr' => 63, 'avg' => 0.288 },
|
|
322
|
+
}
|
|
323
|
+
not_yet_in_python: |
|
|
324
|
+
[{
|
|
325
|
+
'Mark McGwire':
|
|
326
|
+
{ 'hr': 65, 'avg': 0.278 },
|
|
327
|
+
'Sammy Sosa':
|
|
328
|
+
{ 'hr': 63, 'avg': 0.288 }
|
|
329
|
+
}]
|
|
330
|
+
ruby: |
|
|
331
|
+
{
|
|
332
|
+
'Mark McGwire' =>
|
|
333
|
+
{ 'hr' => 65, 'avg' => 0.278 },
|
|
334
|
+
'Sammy Sosa' =>
|
|
335
|
+
{ 'hr' => 63, 'avg' => 0.288 }
|
|
336
|
+
}
|
|
337
|
+
syck: |
|
|
338
|
+
struct test_node map1[] = {
|
|
339
|
+
{ T_STR, 0, "hr" },
|
|
340
|
+
{ T_STR, 0, "65" },
|
|
341
|
+
{ T_STR, 0, "avg" },
|
|
342
|
+
{ T_STR, 0, "0.278" },
|
|
343
|
+
end_node
|
|
344
|
+
};
|
|
345
|
+
struct test_node map2[] = {
|
|
346
|
+
{ T_STR, 0, "hr" },
|
|
347
|
+
{ T_STR, 0, "63" },
|
|
348
|
+
{ T_STR, 0, "avg" },
|
|
349
|
+
{ T_STR, 0, "0.288" },
|
|
350
|
+
end_node
|
|
351
|
+
};
|
|
352
|
+
struct test_node map[] = {
|
|
353
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
354
|
+
{ T_MAP, 0, 0, map1 },
|
|
355
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
356
|
+
{ T_MAP, 0, 0, map2 },
|
|
357
|
+
end_node
|
|
358
|
+
};
|
|
359
|
+
struct test_node stream[] = {
|
|
360
|
+
{ T_MAP, 0, 0, map },
|
|
361
|
+
end_node
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
test: Two documents in a stream each with a
|
|
366
|
+
leading comment
|
|
367
|
+
spec: 2.7
|
|
368
|
+
yaml: |
|
|
369
|
+
# Ranking of 1998 home runs
|
|
370
|
+
---
|
|
371
|
+
- Mark McGwire
|
|
372
|
+
- Sammy Sosa
|
|
373
|
+
- Ken Griffey
|
|
374
|
+
|
|
375
|
+
# Team ranking
|
|
376
|
+
---
|
|
377
|
+
- Chicago Cubs
|
|
378
|
+
- St Louis Cardinals
|
|
379
|
+
perl: |
|
|
380
|
+
{ name => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278 },
|
|
381
|
+
{ name => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288 }
|
|
382
|
+
python: |
|
|
383
|
+
[
|
|
384
|
+
{ 'name': 'Mark McGwire', 'hr': 65, 'avg': 0.278 },
|
|
385
|
+
{ 'name': 'Sammy Sosa', 'hr': 63, 'avg': 0.288 }
|
|
386
|
+
]
|
|
387
|
+
ruby: |
|
|
388
|
+
y = YAML::Stream.new
|
|
389
|
+
y.add( [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] )
|
|
390
|
+
y.add( [ 'Chicago Cubs', 'St Louis Cardinals' ] )
|
|
391
|
+
syck: |
|
|
392
|
+
struct test_node seq1[] = {
|
|
393
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
394
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
395
|
+
{ T_STR, 0, "Ken Griffey" },
|
|
396
|
+
end_node
|
|
397
|
+
};
|
|
398
|
+
struct test_node seq2[] = {
|
|
399
|
+
{ T_STR, 0, "Chicago Cubs" },
|
|
400
|
+
{ T_STR, 0, "St Louis Cardinals" },
|
|
401
|
+
end_node
|
|
402
|
+
};
|
|
403
|
+
struct test_node stream[] = {
|
|
404
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
405
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
406
|
+
end_node
|
|
407
|
+
};
|
|
408
|
+
documents: 2
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
test: Play by play feed from a game
|
|
412
|
+
spec: 2.8
|
|
413
|
+
yaml: |
|
|
414
|
+
---
|
|
415
|
+
time: 20:03:20
|
|
416
|
+
player: Sammy Sosa
|
|
417
|
+
action: strike (miss)
|
|
418
|
+
...
|
|
419
|
+
---
|
|
420
|
+
time: 20:03:47
|
|
421
|
+
player: Sammy Sosa
|
|
422
|
+
action: grand slam
|
|
423
|
+
...
|
|
424
|
+
perl: |
|
|
425
|
+
[ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
|
|
426
|
+
python: |
|
|
427
|
+
[[ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]]
|
|
428
|
+
ruby: |
|
|
429
|
+
y = YAML::Stream.new
|
|
430
|
+
y.add( {"player"=>"Sammy Sosa", "time"=>72200, "action"=>"strike (miss)"} )
|
|
431
|
+
y.add( {"player"=>"Sammy Sosa", "time"=>72227, "action"=>"grand slam"} )
|
|
432
|
+
syck: |
|
|
433
|
+
struct test_node map1[] = {
|
|
434
|
+
{ T_STR, 0, "time" },
|
|
435
|
+
{ T_STR, 0, "20:03:20" },
|
|
436
|
+
{ T_STR, 0, "player" },
|
|
437
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
438
|
+
{ T_STR, 0, "action" },
|
|
439
|
+
{ T_STR, 0, "strike (miss)" },
|
|
440
|
+
end_node
|
|
441
|
+
};
|
|
442
|
+
struct test_node map2[] = {
|
|
443
|
+
{ T_STR, 0, "time" },
|
|
444
|
+
{ T_STR, 0, "20:03:47" },
|
|
445
|
+
{ T_STR, 0, "player" },
|
|
446
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
447
|
+
{ T_STR, 0, "action" },
|
|
448
|
+
{ T_STR, 0, "grand slam" },
|
|
449
|
+
end_node
|
|
450
|
+
};
|
|
451
|
+
struct test_node stream[] = {
|
|
452
|
+
{ T_MAP, 0, 0, map1 },
|
|
453
|
+
{ T_MAP, 0, 0, map2 },
|
|
454
|
+
end_node
|
|
455
|
+
};
|
|
456
|
+
documents: 2
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
test: Single document with two comments
|
|
460
|
+
spec: 2.9
|
|
461
|
+
yaml: |
|
|
462
|
+
hr: # 1998 hr ranking
|
|
463
|
+
- Mark McGwire
|
|
464
|
+
- Sammy Sosa
|
|
465
|
+
rbi:
|
|
466
|
+
# 1998 rbi ranking
|
|
467
|
+
- Sammy Sosa
|
|
468
|
+
- Ken Griffey
|
|
469
|
+
perl-xxx: |
|
|
470
|
+
{
|
|
471
|
+
'hr' => [ 'Mark McGwire', 'Sammy Sosa' ],
|
|
472
|
+
'rbi' => [ 'Sammy Sosa', 'Ken Griffey' ]
|
|
473
|
+
}
|
|
474
|
+
python: |
|
|
475
|
+
[{
|
|
476
|
+
'hr': [ 'Mark McGwire', 'Sammy Sosa' ],
|
|
477
|
+
'rbi': [ 'Sammy Sosa', 'Ken Griffey' ]
|
|
478
|
+
}]
|
|
479
|
+
ruby: |
|
|
480
|
+
{
|
|
481
|
+
'hr' => [ 'Mark McGwire', 'Sammy Sosa' ],
|
|
482
|
+
'rbi' => [ 'Sammy Sosa', 'Ken Griffey' ]
|
|
483
|
+
}
|
|
484
|
+
syck: |
|
|
485
|
+
struct test_node seq1[] = {
|
|
486
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
487
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
488
|
+
end_node
|
|
489
|
+
};
|
|
490
|
+
struct test_node seq2[] = {
|
|
491
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
492
|
+
{ T_STR, 0, "Ken Griffey" },
|
|
493
|
+
end_node
|
|
494
|
+
};
|
|
495
|
+
struct test_node map[] = {
|
|
496
|
+
{ T_STR, 0, "hr" },
|
|
497
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
498
|
+
{ T_STR, 0, "rbi" },
|
|
499
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
500
|
+
end_node
|
|
501
|
+
};
|
|
502
|
+
struct test_node stream[] = {
|
|
503
|
+
{ T_MAP, 0, 0, map },
|
|
504
|
+
end_node
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
test: Node for Sammy Sosa appears twice in this document
|
|
509
|
+
spec: 2.10
|
|
510
|
+
yaml: |
|
|
511
|
+
---
|
|
512
|
+
hr:
|
|
513
|
+
- Mark McGwire
|
|
514
|
+
# Following node labeled SS
|
|
515
|
+
- &SS Sammy Sosa
|
|
516
|
+
rbi:
|
|
517
|
+
- *SS # Subsequent occurance
|
|
518
|
+
- Ken Griffey
|
|
519
|
+
perl: |
|
|
520
|
+
{
|
|
521
|
+
'hr' => [ 'Mark McGwire', 'Sammy Sosa' ],
|
|
522
|
+
'rbi' => [ 'Sammy Sosa', 'Ken Griffey' ]
|
|
523
|
+
}
|
|
524
|
+
python: |
|
|
525
|
+
[{
|
|
526
|
+
'hr': [ 'Mark McGwire', 'Sammy Sosa' ],
|
|
527
|
+
'rbi': [ 'Sammy Sosa', 'Ken Griffey' ]
|
|
528
|
+
}]
|
|
529
|
+
ruby: |
|
|
530
|
+
{
|
|
531
|
+
'hr' =>
|
|
532
|
+
[ 'Mark McGwire', 'Sammy Sosa' ],
|
|
533
|
+
'rbi' =>
|
|
534
|
+
[ 'Sammy Sosa', 'Ken Griffey' ]
|
|
535
|
+
}
|
|
536
|
+
syck: |
|
|
537
|
+
struct test_node seq1[] = {
|
|
538
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
539
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
540
|
+
end_node
|
|
541
|
+
};
|
|
542
|
+
struct test_node seq2[] = {
|
|
543
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
544
|
+
{ T_STR, 0, "Ken Griffey" },
|
|
545
|
+
end_node
|
|
546
|
+
};
|
|
547
|
+
struct test_node map[] = {
|
|
548
|
+
{ T_STR, 0, "hr" },
|
|
549
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
550
|
+
{ T_STR, 0, "rbi" },
|
|
551
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
552
|
+
end_node
|
|
553
|
+
};
|
|
554
|
+
struct test_node stream[] = {
|
|
555
|
+
{ T_MAP, 0, 0, map },
|
|
556
|
+
end_node
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
test: Mapping between sequences
|
|
561
|
+
spec: 2.11
|
|
562
|
+
yaml: |
|
|
563
|
+
? # PLAY SCHEDULE
|
|
564
|
+
- Detroit Tigers
|
|
565
|
+
- Chicago Cubs
|
|
566
|
+
:
|
|
567
|
+
- 2001-07-23
|
|
568
|
+
|
|
569
|
+
? [ New York Yankees,
|
|
570
|
+
Atlanta Braves ]
|
|
571
|
+
: [ 2001-07-02, 2001-08-12,
|
|
572
|
+
2001-08-14 ]
|
|
573
|
+
ruby: |
|
|
574
|
+
{
|
|
575
|
+
[ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
|
|
576
|
+
[ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ]
|
|
577
|
+
}
|
|
578
|
+
syck: |
|
|
579
|
+
struct test_node seq1[] = {
|
|
580
|
+
{ T_STR, 0, "New York Yankees" },
|
|
581
|
+
{ T_STR, 0, "Atlanta Braves" },
|
|
582
|
+
end_node
|
|
583
|
+
};
|
|
584
|
+
struct test_node seq2[] = {
|
|
585
|
+
{ T_STR, 0, "2001-07-02" },
|
|
586
|
+
{ T_STR, 0, "2001-08-12" },
|
|
587
|
+
{ T_STR, 0, "2001-08-14" },
|
|
588
|
+
end_node
|
|
589
|
+
};
|
|
590
|
+
struct test_node seq3[] = {
|
|
591
|
+
{ T_STR, 0, "Detroit Tigers" },
|
|
592
|
+
{ T_STR, 0, "Chicago Cubs" },
|
|
593
|
+
end_node
|
|
594
|
+
};
|
|
595
|
+
struct test_node seq4[] = {
|
|
596
|
+
{ T_STR, 0, "2001-07-23" },
|
|
597
|
+
end_node
|
|
598
|
+
};
|
|
599
|
+
struct test_node map[] = {
|
|
600
|
+
{ T_SEQ, 0, 0, seq3 },
|
|
601
|
+
{ T_SEQ, 0, 0, seq4 },
|
|
602
|
+
{ T_SEQ, 0, 0, seq1 },
|
|
603
|
+
{ T_SEQ, 0, 0, seq2 },
|
|
604
|
+
end_node
|
|
605
|
+
};
|
|
606
|
+
struct test_node stream[] = {
|
|
607
|
+
{ T_MAP, 0, 0, map },
|
|
608
|
+
end_node
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
---
|
|
612
|
+
test: Sequence key shortcut
|
|
613
|
+
spec: 2.12
|
|
614
|
+
yaml: |
|
|
615
|
+
---
|
|
616
|
+
# products purchased
|
|
617
|
+
- item : Super Hoop
|
|
618
|
+
quantity: 1
|
|
619
|
+
- item : Basketball
|
|
620
|
+
quantity: 4
|
|
621
|
+
- item : Big Shoes
|
|
622
|
+
quantity: 1
|
|
623
|
+
perl: |
|
|
624
|
+
[
|
|
625
|
+
{ item => 'Super Hoop', quantity => 1 },
|
|
626
|
+
{ item => 'Basketball', quantity => 4 },
|
|
627
|
+
{ item => 'Big Shoes', quantity => 1 }
|
|
628
|
+
]
|
|
629
|
+
|
|
630
|
+
ruby: |
|
|
631
|
+
[
|
|
632
|
+
{ 'item' => 'Super Hoop', 'quantity' => 1 },
|
|
633
|
+
{ 'item' => 'Basketball', 'quantity' => 4 },
|
|
634
|
+
{ 'item' => 'Big Shoes', 'quantity' => 1 }
|
|
635
|
+
]
|
|
636
|
+
python: |
|
|
637
|
+
[
|
|
638
|
+
{ 'item': 'Super Hoop', 'quantity': 1 },
|
|
639
|
+
{ 'item': 'Basketball', 'quantity': 4 },
|
|
640
|
+
{ 'item': 'Big Shoes', 'quantity': 1 }
|
|
641
|
+
]
|
|
642
|
+
syck: |
|
|
643
|
+
struct test_node map1[] = {
|
|
644
|
+
{ T_STR, 0, "item" },
|
|
645
|
+
{ T_STR, 0, "Super Hoop" },
|
|
646
|
+
{ T_STR, 0, "quantity" },
|
|
647
|
+
{ T_STR, 0, "1" },
|
|
648
|
+
end_node
|
|
649
|
+
};
|
|
650
|
+
struct test_node map2[] = {
|
|
651
|
+
{ T_STR, 0, "item" },
|
|
652
|
+
{ T_STR, 0, "Basketball" },
|
|
653
|
+
{ T_STR, 0, "quantity" },
|
|
654
|
+
{ T_STR, 0, "4" },
|
|
655
|
+
end_node
|
|
656
|
+
};
|
|
657
|
+
struct test_node map3[] = {
|
|
658
|
+
{ T_STR, 0, "item" },
|
|
659
|
+
{ T_STR, 0, "Big Shoes" },
|
|
660
|
+
{ T_STR, 0, "quantity" },
|
|
661
|
+
{ T_STR, 0, "1" },
|
|
662
|
+
end_node
|
|
663
|
+
};
|
|
664
|
+
struct test_node seq[] = {
|
|
665
|
+
{ T_MAP, 0, 0, map1 },
|
|
666
|
+
{ T_MAP, 0, 0, map2 },
|
|
667
|
+
{ T_MAP, 0, 0, map3 },
|
|
668
|
+
end_node
|
|
669
|
+
};
|
|
670
|
+
struct test_node stream[] = {
|
|
671
|
+
{ T_SEQ, 0, 0, seq },
|
|
672
|
+
end_node
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
---
|
|
677
|
+
test: Literal perserves newlines
|
|
678
|
+
spec: 2.13
|
|
679
|
+
yaml: |
|
|
680
|
+
# ASCII Art
|
|
681
|
+
--- |
|
|
682
|
+
\//||\/||
|
|
683
|
+
// || ||_
|
|
684
|
+
perl: |
|
|
685
|
+
"\\//||\\/||\n// || ||_\n"
|
|
686
|
+
ruby: |
|
|
687
|
+
"\\//||\\/||\n// || ||_\n"
|
|
688
|
+
python: |
|
|
689
|
+
[
|
|
690
|
+
flushLeft(
|
|
691
|
+
"""
|
|
692
|
+
\//||\/||
|
|
693
|
+
// || ||_
|
|
694
|
+
"""
|
|
695
|
+
)
|
|
696
|
+
]
|
|
697
|
+
syck: |
|
|
698
|
+
struct test_node stream[] = {
|
|
699
|
+
{ T_STR, 0, "\\//||\\/||\n// || ||_\n" },
|
|
700
|
+
end_node
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
test: Folded treats newlines as a space
|
|
705
|
+
spec: 2.14
|
|
706
|
+
yaml: |
|
|
707
|
+
---
|
|
708
|
+
Mark McGwire's
|
|
709
|
+
year was crippled
|
|
710
|
+
by a knee injury.
|
|
711
|
+
perl: |
|
|
712
|
+
"Mark McGwire's year was crippled by a knee injury."
|
|
713
|
+
ruby: |
|
|
714
|
+
"Mark McGwire's year was crippled by a knee injury."
|
|
715
|
+
python: |
|
|
716
|
+
[ "Mark McGwire's year was crippled by a knee injury." ]
|
|
717
|
+
syck: |
|
|
718
|
+
struct test_node stream[] = {
|
|
719
|
+
{ T_STR, 0, "Mark McGwire's year was crippled by a knee injury." },
|
|
720
|
+
end_node
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
---
|
|
724
|
+
test: Newlines preserved for indented and blank lines
|
|
725
|
+
spec: 2.15
|
|
726
|
+
yaml: |
|
|
727
|
+
--- >
|
|
728
|
+
Sammy Sosa completed another
|
|
729
|
+
fine season with great stats.
|
|
730
|
+
|
|
731
|
+
63 Home Runs
|
|
732
|
+
0.288 Batting Average
|
|
733
|
+
|
|
734
|
+
What a year!
|
|
735
|
+
perl: |
|
|
736
|
+
"Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
|
|
737
|
+
ruby: |
|
|
738
|
+
"Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
|
|
739
|
+
python: |
|
|
740
|
+
[
|
|
741
|
+
flushLeft(
|
|
742
|
+
"""
|
|
743
|
+
Sammy Sosa completed another fine season with great stats.
|
|
744
|
+
|
|
745
|
+
63 Home Runs
|
|
746
|
+
0.288 Batting Average
|
|
747
|
+
|
|
748
|
+
What a year!
|
|
749
|
+
"""
|
|
750
|
+
)
|
|
751
|
+
]
|
|
752
|
+
syck: |
|
|
753
|
+
struct test_node stream[] = {
|
|
754
|
+
{ 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" },
|
|
755
|
+
end_node
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
---
|
|
760
|
+
test: Indentation determines scope
|
|
761
|
+
spec: 2.16
|
|
762
|
+
yaml: |
|
|
763
|
+
name: Mark McGwire
|
|
764
|
+
accomplishment: >
|
|
765
|
+
Mark set a major league
|
|
766
|
+
home run record in 1998.
|
|
767
|
+
stats: |
|
|
768
|
+
65 Home Runs
|
|
769
|
+
0.278 Batting Average
|
|
770
|
+
perl: |
|
|
771
|
+
{
|
|
772
|
+
name => 'Mark McGwire',
|
|
773
|
+
accomplishment => "Mark set a major league home run record in 1998.\n",
|
|
774
|
+
stats => "65 Home Runs\n0.278 Batting Average\n"
|
|
775
|
+
}
|
|
776
|
+
ruby: |
|
|
777
|
+
{
|
|
778
|
+
'name' => 'Mark McGwire', 'accomplishment' => "Mark set a major league home run record in 1998.\n",
|
|
779
|
+
'stats' => "65 Home Runs\n0.278 Batting Average\n"
|
|
780
|
+
}
|
|
781
|
+
python: |
|
|
782
|
+
[
|
|
783
|
+
{
|
|
784
|
+
'name': 'Mark McGwire',
|
|
785
|
+
'accomplishment':
|
|
786
|
+
'Mark set a major league home run record in 1998.\n',
|
|
787
|
+
'stats': "65 Home Runs\n0.278 Batting Average\n"
|
|
788
|
+
}
|
|
789
|
+
]
|
|
790
|
+
syck: |
|
|
791
|
+
struct test_node map[] = {
|
|
792
|
+
{ T_STR, 0, "name" },
|
|
793
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
794
|
+
{ T_STR, 0, "accomplishment" },
|
|
795
|
+
{ T_STR, 0, "Mark set a major league home run record in 1998.\n" },
|
|
796
|
+
{ T_STR, 0, "stats" },
|
|
797
|
+
{ T_STR, 0, "65 Home Runs\n0.278 Batting Average\n" },
|
|
798
|
+
end_node
|
|
799
|
+
};
|
|
800
|
+
struct test_node stream[] = {
|
|
801
|
+
{ T_MAP, 0, 0, map },
|
|
802
|
+
end_node
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
---
|
|
806
|
+
test: Quoted scalars
|
|
807
|
+
spec: 2.17
|
|
808
|
+
yaml: |
|
|
809
|
+
unicode: "Sosa did fine.\u263A"
|
|
810
|
+
control: "\b1998\t1999\t2000\n"
|
|
811
|
+
hexesc: "\x0D\x0A is \r\n"
|
|
812
|
+
|
|
813
|
+
single: '"Howdy!" he cried.'
|
|
814
|
+
quoted: ' # not a ''comment''.'
|
|
815
|
+
tie-fighter: '|\-*-/|'
|
|
816
|
+
perl-not-working: |
|
|
817
|
+
{
|
|
818
|
+
unicode => "Sosa did fine.\x{263A}",
|
|
819
|
+
control => "\x081998\t1999\t2000\n",
|
|
820
|
+
hexesc => "\r\n is \r\n",
|
|
821
|
+
single => '"Howdy!" he cried.',
|
|
822
|
+
quoted => " # not a 'comment'.",
|
|
823
|
+
"tie-fighter" => '|\\-*-/|',
|
|
824
|
+
}
|
|
825
|
+
ruby: |
|
|
826
|
+
{
|
|
827
|
+
"tie-fighter" => "|\\-*-/|",
|
|
828
|
+
"control"=>"\0101998\t1999\t2000\n",
|
|
829
|
+
"unicode"=>"Sosa did fine." + ["263A".hex ].pack('U*'),
|
|
830
|
+
"quoted"=>" # not a 'comment'.",
|
|
831
|
+
"single"=>"\"Howdy!\" he cried.",
|
|
832
|
+
"hexesc"=>"\r\n is \r\n"
|
|
833
|
+
}
|
|
834
|
+
python: |
|
|
835
|
+
[ {
|
|
836
|
+
'unicode': u"Sosa did fine.\u263A",
|
|
837
|
+
'control': "\b1998\t1999\t2000\n",
|
|
838
|
+
'hexesc': "\x0D\x0A is \r\n",
|
|
839
|
+
'single': '"Howdy!" he cried.',
|
|
840
|
+
'quoted': ' # not a \'comment\'.',
|
|
841
|
+
'tie-fighter': '|\-*-/|',
|
|
842
|
+
} ]
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
---
|
|
846
|
+
test: Multiline flow scalars
|
|
847
|
+
spec: 2.18
|
|
848
|
+
yaml: |
|
|
849
|
+
plain:
|
|
850
|
+
This unquoted scalar
|
|
851
|
+
spans many lines.
|
|
852
|
+
|
|
853
|
+
quoted: "So does this
|
|
854
|
+
quoted scalar.\n"
|
|
855
|
+
perl-not-working: |
|
|
856
|
+
{
|
|
857
|
+
plain => 'This unquoted scalar spans many lines.',
|
|
858
|
+
quoted => "So does this quoted scalar.\n"
|
|
859
|
+
}
|
|
860
|
+
ruby: |
|
|
861
|
+
{
|
|
862
|
+
'plain' => 'This unquoted scalar spans many lines.',
|
|
863
|
+
'quoted' => "So does this quoted scalar.\n"
|
|
864
|
+
}
|
|
865
|
+
python: |
|
|
866
|
+
[ {
|
|
867
|
+
'plain': 'This unquoted scalar spans many lines.',
|
|
868
|
+
'quoted': 'So does this quoted scalar.\n'
|
|
869
|
+
}
|
|
870
|
+
]
|
|
871
|
+
syck: |
|
|
872
|
+
struct test_node map[] = {
|
|
873
|
+
{ T_STR, 0, "plain" },
|
|
874
|
+
{ T_STR, 0, "This unquoted scalar spans many lines." },
|
|
875
|
+
{ T_STR, 0, "quoted" },
|
|
876
|
+
{ T_STR, 0, "So does this quoted scalar.\n" },
|
|
877
|
+
end_node
|
|
878
|
+
};
|
|
879
|
+
struct test_node stream[] = {
|
|
880
|
+
{ T_MAP, 0, 0, map },
|
|
881
|
+
end_node
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
---
|
|
885
|
+
test: Integers
|
|
886
|
+
spec: 2.19
|
|
887
|
+
yaml: |
|
|
888
|
+
canonical: 12345
|
|
889
|
+
decimal: +12,345
|
|
890
|
+
sexagecimal: 3:25:45
|
|
891
|
+
octal: 014
|
|
892
|
+
hexadecimal: 0xC
|
|
893
|
+
perl: |
|
|
894
|
+
{
|
|
895
|
+
canonical => 12345,
|
|
896
|
+
decimal => 12345,
|
|
897
|
+
octal => oct("014"),
|
|
898
|
+
hexadecimal => hex("0xC"),
|
|
899
|
+
}
|
|
900
|
+
ruby: |
|
|
901
|
+
{
|
|
902
|
+
'canonical' => 12345,
|
|
903
|
+
'decimal' => 12345,
|
|
904
|
+
'sexagecimal' => 12345,
|
|
905
|
+
'octal' => '014'.oct,
|
|
906
|
+
'hexadecimal' => '0xC'.hex
|
|
907
|
+
}
|
|
908
|
+
python: |
|
|
909
|
+
[ {
|
|
910
|
+
'canonical': 12345,
|
|
911
|
+
'decimal': 12345,
|
|
912
|
+
'octal': 014,
|
|
913
|
+
'hexadecimal': 0xC
|
|
914
|
+
} ]
|
|
915
|
+
syck: |
|
|
916
|
+
struct test_node map[] = {
|
|
917
|
+
{ T_STR, 0, "canonical" },
|
|
918
|
+
{ T_STR, 0, "12345" },
|
|
919
|
+
{ T_STR, 0, "decimal" },
|
|
920
|
+
{ T_STR, 0, "+12,345" },
|
|
921
|
+
{ T_STR, 0, "sexagecimal" },
|
|
922
|
+
{ T_STR, 0, "3:25:45" },
|
|
923
|
+
{ T_STR, 0, "octal" },
|
|
924
|
+
{ T_STR, 0, "014" },
|
|
925
|
+
{ T_STR, 0, "hexadecimal" },
|
|
926
|
+
{ T_STR, 0, "0xC" },
|
|
927
|
+
end_node
|
|
928
|
+
};
|
|
929
|
+
struct test_node stream[] = {
|
|
930
|
+
{ T_MAP, 0, 0, map },
|
|
931
|
+
end_node
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
---
|
|
935
|
+
# FIX: spec shows parens around -inf and NaN
|
|
936
|
+
test: Floating point
|
|
937
|
+
spec: 2.20
|
|
938
|
+
yaml: |
|
|
939
|
+
canonical: 1.23015e+3
|
|
940
|
+
exponential: 12.3015e+02
|
|
941
|
+
sexagecimal: 20:30.15
|
|
942
|
+
fixed: 1,230.15
|
|
943
|
+
negative infinity: -.inf
|
|
944
|
+
not a number: .NaN
|
|
945
|
+
perl: |
|
|
946
|
+
{
|
|
947
|
+
'canonical' => 1230.15,
|
|
948
|
+
'exponential' => 1230.15,
|
|
949
|
+
'fixed' => 1230.15,
|
|
950
|
+
'negative infinity' => "-.inf",
|
|
951
|
+
'not a number' => ".NaN",
|
|
952
|
+
}
|
|
953
|
+
ruby: |
|
|
954
|
+
{
|
|
955
|
+
'canonical' => 1230.15,
|
|
956
|
+
'exponential' => 1230.15,
|
|
957
|
+
'sexagecimal' => 1230.15,
|
|
958
|
+
'fixed' => 1230.15,
|
|
959
|
+
'negative infinity' => -1.0/0.0,
|
|
960
|
+
'not a number' => 0.0/0.0
|
|
961
|
+
}
|
|
962
|
+
if obj_y['not a number'].nan? # NaN comparison doesn't work right against 0.0/0.0
|
|
963
|
+
obj_r['not a number'] = obj_y['not a number']
|
|
964
|
+
end
|
|
965
|
+
python: |
|
|
966
|
+
[ {
|
|
967
|
+
'canonical': 1.23015e+3,
|
|
968
|
+
'exponential': 1.23015e+3,
|
|
969
|
+
'fixed': 1230.15,
|
|
970
|
+
'negative infinity': '-.inf',
|
|
971
|
+
'not a number': '.NaN',
|
|
972
|
+
} ]
|
|
973
|
+
syck: |
|
|
974
|
+
struct test_node map[] = {
|
|
975
|
+
{ T_STR, 0, "canonical" },
|
|
976
|
+
{ T_STR, 0, "1.23015e+3" },
|
|
977
|
+
{ T_STR, 0, "exponential" },
|
|
978
|
+
{ T_STR, 0, "12.3015e+02" },
|
|
979
|
+
{ T_STR, 0, "sexagecimal" },
|
|
980
|
+
{ T_STR, 0, "20:30.15" },
|
|
981
|
+
{ T_STR, 0, "fixed" },
|
|
982
|
+
{ T_STR, 0, "1,230.15" },
|
|
983
|
+
{ T_STR, 0, "negative infinity" },
|
|
984
|
+
{ T_STR, 0, "-.inf" },
|
|
985
|
+
{ T_STR, 0, "not a number" },
|
|
986
|
+
{ T_STR, 0, ".NaN" },
|
|
987
|
+
end_node
|
|
988
|
+
};
|
|
989
|
+
struct test_node stream[] = {
|
|
990
|
+
{ T_MAP, 0, 0, map },
|
|
991
|
+
end_node
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
---
|
|
995
|
+
test: Miscellaneous
|
|
996
|
+
spec: 2.21
|
|
997
|
+
yaml: |
|
|
998
|
+
null: ~
|
|
999
|
+
true: y
|
|
1000
|
+
false: n
|
|
1001
|
+
string: '12345'
|
|
1002
|
+
perl: |
|
|
1003
|
+
{
|
|
1004
|
+
null => undef,
|
|
1005
|
+
true => 1,
|
|
1006
|
+
false => 0,
|
|
1007
|
+
string => "12345"
|
|
1008
|
+
}
|
|
1009
|
+
ruby: |
|
|
1010
|
+
{
|
|
1011
|
+
nil => nil,
|
|
1012
|
+
true => true,
|
|
1013
|
+
false => false,
|
|
1014
|
+
'string' => '12345'
|
|
1015
|
+
}
|
|
1016
|
+
python: |
|
|
1017
|
+
[ {
|
|
1018
|
+
'null': None,
|
|
1019
|
+
'true': 1,
|
|
1020
|
+
'false': 0,
|
|
1021
|
+
'string': '12345',
|
|
1022
|
+
} ]
|
|
1023
|
+
syck: |
|
|
1024
|
+
struct test_node map[] = {
|
|
1025
|
+
{ T_STR, 0, "null" },
|
|
1026
|
+
{ T_STR, 0, "~" },
|
|
1027
|
+
{ T_STR, 0, "true" },
|
|
1028
|
+
{ T_STR, 0, "y" },
|
|
1029
|
+
{ T_STR, 0, "false" },
|
|
1030
|
+
{ T_STR, 0, "n" },
|
|
1031
|
+
{ T_STR, 0, "string" },
|
|
1032
|
+
{ T_STR, 0, "12345" },
|
|
1033
|
+
end_node
|
|
1034
|
+
};
|
|
1035
|
+
struct test_node stream[] = {
|
|
1036
|
+
{ T_MAP, 0, 0, map },
|
|
1037
|
+
end_node
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
---
|
|
1041
|
+
test: Timestamps
|
|
1042
|
+
spec: 2.22
|
|
1043
|
+
yaml: |
|
|
1044
|
+
canonical: 2001-12-15T02:59:43.1Z
|
|
1045
|
+
iso8601: 2001-12-14t21:59:43.10-05:00
|
|
1046
|
+
spaced: 2001-12-14 21:59:43.10 -05:00
|
|
1047
|
+
date: 2002-12-14 # Time is noon UTC
|
|
1048
|
+
perl: |
|
|
1049
|
+
{
|
|
1050
|
+
canonical => "2001-12-15T02:59:43.1Z",
|
|
1051
|
+
iso8601 => "2001-12-14t21:59:43.10-05:00",
|
|
1052
|
+
spaced => "2001-12-14 21:59:43.10 -05:00",
|
|
1053
|
+
date => "2002-12-14",
|
|
1054
|
+
}
|
|
1055
|
+
ruby: |
|
|
1056
|
+
{
|
|
1057
|
+
'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
|
|
1058
|
+
'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
|
|
1059
|
+
'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
|
|
1060
|
+
'date' => Date.new( 2002, 12, 14 )
|
|
1061
|
+
}
|
|
1062
|
+
syck: |
|
|
1063
|
+
struct test_node map[] = {
|
|
1064
|
+
{ T_STR, 0, "canonical" },
|
|
1065
|
+
{ T_STR, 0, "2001-12-15T02:59:43.1Z" },
|
|
1066
|
+
{ T_STR, 0, "iso8601" },
|
|
1067
|
+
{ T_STR, 0, "2001-12-14t21:59:43.10-05:00" },
|
|
1068
|
+
{ T_STR, 0, "spaced" },
|
|
1069
|
+
{ T_STR, 0, "2001-12-14 21:59:43.10 -05:00" },
|
|
1070
|
+
{ T_STR, 0, "date" },
|
|
1071
|
+
{ T_STR, 0, "2002-12-14" },
|
|
1072
|
+
end_node
|
|
1073
|
+
};
|
|
1074
|
+
struct test_node stream[] = {
|
|
1075
|
+
{ T_MAP, 0, 0, map },
|
|
1076
|
+
end_node
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
---
|
|
1080
|
+
test: legacy Timestamps test
|
|
1081
|
+
spec: legacy D4
|
|
1082
|
+
yaml: |
|
|
1083
|
+
canonical: 2001-12-15T02:59:43.00Z
|
|
1084
|
+
iso8601: 2001-02-28t21:59:43.00-05:00
|
|
1085
|
+
spaced: 2001-12-14 21:59:43.00 -05:00
|
|
1086
|
+
date: 2002-12-14
|
|
1087
|
+
python: |
|
|
1088
|
+
[ {
|
|
1089
|
+
'canonical': yaml.timestamp('2001-12-15T02:59:43.00Z'),
|
|
1090
|
+
'iso8601': yaml.timestamp('2001-03-01T02:59:43.00Z'),
|
|
1091
|
+
'spaced': yaml.timestamp('2001-12-15T02:59:43.00Z'),
|
|
1092
|
+
'date': yaml.timestamp('2002-12-14T00:00:00.00Z')
|
|
1093
|
+
} ]
|
|
1094
|
+
ruby: |
|
|
1095
|
+
{
|
|
1096
|
+
'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
|
|
1097
|
+
'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
|
|
1098
|
+
'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
|
|
1099
|
+
'date' => Date.new( 2002, 12, 14 )
|
|
1100
|
+
}
|
|
1101
|
+
syck: |
|
|
1102
|
+
struct test_node map[] = {
|
|
1103
|
+
{ T_STR, 0, "canonical" },
|
|
1104
|
+
{ T_STR, 0, "2001-12-15T02:59:43.00Z" },
|
|
1105
|
+
{ T_STR, 0, "iso8601" },
|
|
1106
|
+
{ T_STR, 0, "2001-02-28t21:59:43.00-05:00" },
|
|
1107
|
+
{ T_STR, 0, "spaced" },
|
|
1108
|
+
{ T_STR, 0, "2001-12-14 21:59:43.00 -05:00" },
|
|
1109
|
+
{ T_STR, 0, "date" },
|
|
1110
|
+
{ T_STR, 0, "2002-12-14" },
|
|
1111
|
+
end_node
|
|
1112
|
+
};
|
|
1113
|
+
struct test_node stream[] = {
|
|
1114
|
+
{ T_MAP, 0, 0, map },
|
|
1115
|
+
end_node
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
---
|
|
1119
|
+
test: Various explicit families
|
|
1120
|
+
spec: 2.23
|
|
1121
|
+
yaml: |
|
|
1122
|
+
not-date: !str 2002-04-28
|
|
1123
|
+
picture: !binary |
|
|
1124
|
+
R0lGODlhDAAMAIQAAP//9/X
|
|
1125
|
+
17unp5WZmZgAAAOfn515eXv
|
|
1126
|
+
Pz7Y6OjuDg4J+fn5OTk6enp
|
|
1127
|
+
56enmleECcgggoBADs=
|
|
1128
|
+
|
|
1129
|
+
application specific tag: !!something |
|
|
1130
|
+
The semantics of the tag
|
|
1131
|
+
above may be different for
|
|
1132
|
+
different documents.
|
|
1133
|
+
|
|
1134
|
+
ruby-setup: |
|
|
1135
|
+
YAML.add_private_type( "something" ) do |type, val|
|
|
1136
|
+
"SOMETHING: #{val}"
|
|
1137
|
+
end
|
|
1138
|
+
ruby: |
|
|
1139
|
+
{
|
|
1140
|
+
'not-date' => '2002-04-28',
|
|
1141
|
+
'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;",
|
|
1142
|
+
'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n"
|
|
1143
|
+
}
|
|
1144
|
+
syck: |
|
|
1145
|
+
struct test_node map[] = {
|
|
1146
|
+
{ T_STR, 0, "not-date" },
|
|
1147
|
+
{ T_STR, "tag:yaml.org,2002:str", "2002-04-28" },
|
|
1148
|
+
{ T_STR, 0, "picture" },
|
|
1149
|
+
{ T_STR, "tag:yaml.org,2002:binary", "R0lGODlhDAAMAIQAAP//9/X\n17unp5WZmZgAAAOfn515eXv\nPz7Y6OjuDg4J+fn5OTk6enp\n56enmleECcgggoBADs=\n" },
|
|
1150
|
+
{ T_STR, 0, "application specific tag" },
|
|
1151
|
+
{ T_STR, "x-private:something", "The semantics of the tag\nabove may be different for\ndifferent documents.\n" },
|
|
1152
|
+
end_node
|
|
1153
|
+
};
|
|
1154
|
+
struct test_node stream[] = {
|
|
1155
|
+
{ T_MAP, 0, 0, map },
|
|
1156
|
+
end_node
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
---
|
|
1160
|
+
test: Application specific family
|
|
1161
|
+
spec: 2.24
|
|
1162
|
+
yaml: |
|
|
1163
|
+
# Establish a tag prefix
|
|
1164
|
+
--- !clarkevans.com,2002/graph/^shape
|
|
1165
|
+
# Use the prefix: shorthand for
|
|
1166
|
+
# !clarkevans.com,2002/graph/circle
|
|
1167
|
+
- !^circle
|
|
1168
|
+
center: &ORIGIN {x: 73, 'y': 129}
|
|
1169
|
+
radius: 7
|
|
1170
|
+
- !^line # !clarkevans.com,2002/graph/line
|
|
1171
|
+
start: *ORIGIN
|
|
1172
|
+
finish: { x: 89, 'y': 102 }
|
|
1173
|
+
- !^label
|
|
1174
|
+
start: *ORIGIN
|
|
1175
|
+
color: 0xFFEEBB
|
|
1176
|
+
value: Pretty vector drawing.
|
|
1177
|
+
ruby-setup: |
|
|
1178
|
+
YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
|
|
1179
|
+
if Array === val
|
|
1180
|
+
val << "Shape Container"
|
|
1181
|
+
val
|
|
1182
|
+
else
|
|
1183
|
+
raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
|
|
1184
|
+
end
|
|
1185
|
+
}
|
|
1186
|
+
one_shape_proc = Proc.new { |type, val|
|
|
1187
|
+
scheme, domain, type = type.split( /:/, 3 )
|
|
1188
|
+
if val.is_a? ::Hash
|
|
1189
|
+
val['TYPE'] = "Shape: #{type}"
|
|
1190
|
+
val
|
|
1191
|
+
else
|
|
1192
|
+
raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
|
|
1193
|
+
end
|
|
1194
|
+
}
|
|
1195
|
+
YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
|
|
1196
|
+
YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
|
|
1197
|
+
YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc )
|
|
1198
|
+
ruby: |
|
|
1199
|
+
[
|
|
1200
|
+
{
|
|
1201
|
+
"radius" => 7,
|
|
1202
|
+
"center"=>
|
|
1203
|
+
{
|
|
1204
|
+
"x" => 73,
|
|
1205
|
+
"y" => 129
|
|
1206
|
+
},
|
|
1207
|
+
"TYPE" => "Shape: graph/circle"
|
|
1208
|
+
}, {
|
|
1209
|
+
"finish" =>
|
|
1210
|
+
{
|
|
1211
|
+
"x" => 89,
|
|
1212
|
+
"y" => 102
|
|
1213
|
+
},
|
|
1214
|
+
"TYPE" => "Shape: graph/line",
|
|
1215
|
+
"start" =>
|
|
1216
|
+
{
|
|
1217
|
+
"x" => 73,
|
|
1218
|
+
"y" => 129
|
|
1219
|
+
}
|
|
1220
|
+
}, {
|
|
1221
|
+
"TYPE" => "Shape: graph/label",
|
|
1222
|
+
"value" => "Pretty vector drawing.",
|
|
1223
|
+
"start" =>
|
|
1224
|
+
{
|
|
1225
|
+
"x" => 73,
|
|
1226
|
+
"y" => 129
|
|
1227
|
+
},
|
|
1228
|
+
"color" => 16772795
|
|
1229
|
+
},
|
|
1230
|
+
"Shape Container"
|
|
1231
|
+
]
|
|
1232
|
+
syck: |
|
|
1233
|
+
struct test_node point1[] = {
|
|
1234
|
+
{ T_STR, 0, "x" },
|
|
1235
|
+
{ T_STR, 0, "73" },
|
|
1236
|
+
{ T_STR, 0, "y" },
|
|
1237
|
+
{ T_STR, 0, "129" },
|
|
1238
|
+
end_node
|
|
1239
|
+
};
|
|
1240
|
+
struct test_node point2[] = {
|
|
1241
|
+
{ T_STR, 0, "x" },
|
|
1242
|
+
{ T_STR, 0, "89" },
|
|
1243
|
+
{ T_STR, 0, "y" },
|
|
1244
|
+
{ T_STR, 0, "102" },
|
|
1245
|
+
end_node
|
|
1246
|
+
};
|
|
1247
|
+
struct test_node map1[] = {
|
|
1248
|
+
{ T_STR, 0, "center" },
|
|
1249
|
+
{ T_MAP, 0, 0, point1 },
|
|
1250
|
+
{ T_STR, 0, "radius" },
|
|
1251
|
+
{ T_STR, 0, "7" },
|
|
1252
|
+
end_node
|
|
1253
|
+
};
|
|
1254
|
+
struct test_node map2[] = {
|
|
1255
|
+
{ T_STR, 0, "start" },
|
|
1256
|
+
{ T_MAP, 0, 0, point1 },
|
|
1257
|
+
{ T_STR, 0, "finish" },
|
|
1258
|
+
{ T_MAP, 0, 0, point2 },
|
|
1259
|
+
end_node
|
|
1260
|
+
};
|
|
1261
|
+
struct test_node map3[] = {
|
|
1262
|
+
{ T_STR, 0, "start" },
|
|
1263
|
+
{ T_MAP, 0, 0, point1 },
|
|
1264
|
+
{ T_STR, 0, "color" },
|
|
1265
|
+
{ T_STR, 0, "0xFFEEBB" },
|
|
1266
|
+
{ T_STR, 0, "value" },
|
|
1267
|
+
{ T_STR, 0, "Pretty vector drawing." },
|
|
1268
|
+
end_node
|
|
1269
|
+
};
|
|
1270
|
+
struct test_node seq[] = {
|
|
1271
|
+
{ T_MAP, "tag:clarkevans.com,2002:graph/circle", 0, map1 },
|
|
1272
|
+
{ T_MAP, "tag:clarkevans.com,2002:graph/line", 0, map2 },
|
|
1273
|
+
{ T_MAP, "tag:clarkevans.com,2002:graph/label", 0, map3 },
|
|
1274
|
+
end_node
|
|
1275
|
+
};
|
|
1276
|
+
struct test_node stream[] = {
|
|
1277
|
+
{ T_SEQ, "tag:clarkevans.com,2002:graph/shape", 0, seq },
|
|
1278
|
+
end_node
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
# ---
|
|
1282
|
+
# test: Unordered set
|
|
1283
|
+
# spec: 2.25
|
|
1284
|
+
# yaml: |
|
|
1285
|
+
# # sets are represented as a
|
|
1286
|
+
# # mapping where each key is
|
|
1287
|
+
# # associated with the empty string
|
|
1288
|
+
# --- !set
|
|
1289
|
+
# ? Mark McGwire
|
|
1290
|
+
# ? Sammy Sosa
|
|
1291
|
+
# ? Ken Griff
|
|
1292
|
+
---
|
|
1293
|
+
test: Ordered mappings
|
|
1294
|
+
spec: 2.26
|
|
1295
|
+
yaml: |
|
|
1296
|
+
# ordered maps are represented as
|
|
1297
|
+
# a sequence of mappings, with
|
|
1298
|
+
# each mapping having one key
|
|
1299
|
+
--- !omap
|
|
1300
|
+
- Mark McGwire: 65
|
|
1301
|
+
- Sammy Sosa: 63
|
|
1302
|
+
- Ken Griffy: 58
|
|
1303
|
+
ruby: |
|
|
1304
|
+
YAML::Omap[
|
|
1305
|
+
'Mark McGwire', 65,
|
|
1306
|
+
'Sammy Sosa', 63,
|
|
1307
|
+
'Ken Griffy', 58
|
|
1308
|
+
]
|
|
1309
|
+
syck: |
|
|
1310
|
+
struct test_node map1[] = {
|
|
1311
|
+
{ T_STR, 0, "Mark McGwire" },
|
|
1312
|
+
{ T_STR, 0, "65" },
|
|
1313
|
+
end_node
|
|
1314
|
+
};
|
|
1315
|
+
struct test_node map2[] = {
|
|
1316
|
+
{ T_STR, 0, "Sammy Sosa" },
|
|
1317
|
+
{ T_STR, 0, "63" },
|
|
1318
|
+
end_node
|
|
1319
|
+
};
|
|
1320
|
+
struct test_node map3[] = {
|
|
1321
|
+
{ T_STR, 0, "Ken Griffy" },
|
|
1322
|
+
{ T_STR, 0, "58" },
|
|
1323
|
+
end_node
|
|
1324
|
+
};
|
|
1325
|
+
struct test_node seq[] = {
|
|
1326
|
+
{ T_MAP, 0, 0, map1 },
|
|
1327
|
+
{ T_MAP, 0, 0, map2 },
|
|
1328
|
+
{ T_MAP, 0, 0, map3 },
|
|
1329
|
+
end_node
|
|
1330
|
+
};
|
|
1331
|
+
struct test_node stream[] = {
|
|
1332
|
+
{ T_SEQ, "tag:yaml.org,2002:omap", 0, seq },
|
|
1333
|
+
end_node
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
---
|
|
1337
|
+
test: Invoice
|
|
1338
|
+
spec: 2.27
|
|
1339
|
+
yaml: |
|
|
1340
|
+
--- !clarkevans.com,2002/^invoice
|
|
1341
|
+
invoice: 34843
|
|
1342
|
+
date : 2001-01-23
|
|
1343
|
+
bill-to: &id001
|
|
1344
|
+
given : Chris
|
|
1345
|
+
family : Dumars
|
|
1346
|
+
address:
|
|
1347
|
+
lines: |
|
|
1348
|
+
458 Walkman Dr.
|
|
1349
|
+
Suite #292
|
|
1350
|
+
city : Royal Oak
|
|
1351
|
+
state : MI
|
|
1352
|
+
postal : 48046
|
|
1353
|
+
ship-to: *id001
|
|
1354
|
+
product:
|
|
1355
|
+
- sku : BL394D
|
|
1356
|
+
quantity : 4
|
|
1357
|
+
description : Basketball
|
|
1358
|
+
price : 450.00
|
|
1359
|
+
- sku : BL4438H
|
|
1360
|
+
quantity : 1
|
|
1361
|
+
description : Super Hoop
|
|
1362
|
+
price : 2392.00
|
|
1363
|
+
tax : 251.42
|
|
1364
|
+
total: 4443.52
|
|
1365
|
+
comments: >
|
|
1366
|
+
Late afternoon is best.
|
|
1367
|
+
Backup contact is Nancy
|
|
1368
|
+
Billsmer @ 338-4338.
|
|
1369
|
+
ruby-setup: |
|
|
1370
|
+
YAML.add_domain_type( "clarkevans.com,2002", "invoice" ) { |type, val| val }
|
|
1371
|
+
id001 = { 'given' => 'Chris', 'family' => 'Dumars', 'address' =>
|
|
1372
|
+
{ 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak',
|
|
1373
|
+
'state' => 'MI', 'postal' => 48046 } }
|
|
1374
|
+
ruby: |
|
|
1375
|
+
{
|
|
1376
|
+
'invoice' => 34843, 'date' => Date.new( 2001, 1, 23 ),
|
|
1377
|
+
'bill-to' => id001, 'ship-to' => id001, 'product' =>
|
|
1378
|
+
[ { 'sku' => 'BL394D', 'quantity' => 4,
|
|
1379
|
+
'description' => 'Basketball', 'price' => 450.00 },
|
|
1380
|
+
{ 'sku' => 'BL4438H', 'quantity' => 1,
|
|
1381
|
+
'description' => 'Super Hoop', 'price' => 2392.00 } ],
|
|
1382
|
+
'tax' => 251.42, 'total' => 4443.52,
|
|
1383
|
+
'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n" }
|
|
1384
|
+
syck: |
|
|
1385
|
+
struct test_node prod1[] = {
|
|
1386
|
+
{ T_STR, 0, "sku" },
|
|
1387
|
+
{ T_STR, 0, "BL394D" },
|
|
1388
|
+
{ T_STR, 0, "quantity" },
|
|
1389
|
+
{ T_STR, 0, "4" },
|
|
1390
|
+
{ T_STR, 0, "description" },
|
|
1391
|
+
{ T_STR, 0, "Basketball" },
|
|
1392
|
+
{ T_STR, 0, "price" },
|
|
1393
|
+
{ T_STR, 0, "450.00" },
|
|
1394
|
+
end_node
|
|
1395
|
+
};
|
|
1396
|
+
struct test_node prod2[] = {
|
|
1397
|
+
{ T_STR, 0, "sku" },
|
|
1398
|
+
{ T_STR, 0, "BL4438H" },
|
|
1399
|
+
{ T_STR, 0, "quantity" },
|
|
1400
|
+
{ T_STR, 0, "1" },
|
|
1401
|
+
{ T_STR, 0, "description" },
|
|
1402
|
+
{ T_STR, 0, "Super Hoop" },
|
|
1403
|
+
{ T_STR, 0, "price" },
|
|
1404
|
+
{ T_STR, 0, "2392.00" },
|
|
1405
|
+
end_node
|
|
1406
|
+
};
|
|
1407
|
+
struct test_node products[] = {
|
|
1408
|
+
{ T_MAP, 0, 0, prod1 },
|
|
1409
|
+
{ T_MAP, 0, 0, prod2 },
|
|
1410
|
+
end_node
|
|
1411
|
+
};
|
|
1412
|
+
struct test_node address[] = {
|
|
1413
|
+
{ T_STR, 0, "lines" },
|
|
1414
|
+
{ T_STR, 0, "458 Walkman Dr.\nSuite #292\n" },
|
|
1415
|
+
{ T_STR, 0, "city" },
|
|
1416
|
+
{ T_STR, 0, "Royal Oak" },
|
|
1417
|
+
{ T_STR, 0, "state" },
|
|
1418
|
+
{ T_STR, 0, "MI" },
|
|
1419
|
+
{ T_STR, 0, "postal" },
|
|
1420
|
+
{ T_STR, 0, "48046" },
|
|
1421
|
+
end_node
|
|
1422
|
+
};
|
|
1423
|
+
struct test_node id001[] = {
|
|
1424
|
+
{ T_STR, 0, "given" },
|
|
1425
|
+
{ T_STR, 0, "Chris" },
|
|
1426
|
+
{ T_STR, 0, "family" },
|
|
1427
|
+
{ T_STR, 0, "Dumars" },
|
|
1428
|
+
{ T_STR, 0, "address" },
|
|
1429
|
+
{ T_MAP, 0, 0, address },
|
|
1430
|
+
end_node
|
|
1431
|
+
};
|
|
1432
|
+
struct test_node map[] = {
|
|
1433
|
+
{ T_STR, 0, "invoice" },
|
|
1434
|
+
{ T_STR, 0, "34843" },
|
|
1435
|
+
{ T_STR, 0, "date" },
|
|
1436
|
+
{ T_STR, 0, "2001-01-23" },
|
|
1437
|
+
{ T_STR, 0, "bill-to" },
|
|
1438
|
+
{ T_MAP, 0, 0, id001 },
|
|
1439
|
+
{ T_STR, 0, "ship-to" },
|
|
1440
|
+
{ T_MAP, 0, 0, id001 },
|
|
1441
|
+
{ T_STR, 0, "product" },
|
|
1442
|
+
{ T_SEQ, 0, 0, products },
|
|
1443
|
+
{ T_STR, 0, "tax" },
|
|
1444
|
+
{ T_STR, 0, "251.42" },
|
|
1445
|
+
{ T_STR, 0, "total" },
|
|
1446
|
+
{ T_STR, 0, "4443.52" },
|
|
1447
|
+
{ T_STR, 0, "comments" },
|
|
1448
|
+
{ T_STR, 0, "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n" },
|
|
1449
|
+
end_node
|
|
1450
|
+
};
|
|
1451
|
+
struct test_node stream[] = {
|
|
1452
|
+
{ T_MAP, "tag:clarkevans.com,2002:invoice", 0, map },
|
|
1453
|
+
end_node
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
---
|
|
1457
|
+
test: Log file
|
|
1458
|
+
spec: 2.28
|
|
1459
|
+
yaml: |
|
|
1460
|
+
---
|
|
1461
|
+
Time: 2001-11-23 15:01:42 -05:00
|
|
1462
|
+
User: ed
|
|
1463
|
+
Warning: >
|
|
1464
|
+
This is an error message
|
|
1465
|
+
for the log file
|
|
1466
|
+
---
|
|
1467
|
+
Time: 2001-11-23 15:02:31 -05:00
|
|
1468
|
+
User: ed
|
|
1469
|
+
Warning: >
|
|
1470
|
+
A slightly different error
|
|
1471
|
+
message.
|
|
1472
|
+
---
|
|
1473
|
+
Date: 2001-11-23 15:03:17 -05:00
|
|
1474
|
+
User: ed
|
|
1475
|
+
Fatal: >
|
|
1476
|
+
Unknown variable "bar"
|
|
1477
|
+
Stack:
|
|
1478
|
+
- file: TopClass.py
|
|
1479
|
+
line: 23
|
|
1480
|
+
code: |
|
|
1481
|
+
x = MoreObject("345\n")
|
|
1482
|
+
- file: MoreClass.py
|
|
1483
|
+
line: 58
|
|
1484
|
+
code: |-
|
|
1485
|
+
foo = bar
|
|
1486
|
+
ruby: |
|
|
1487
|
+
y = YAML::Stream.new
|
|
1488
|
+
y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ),
|
|
1489
|
+
'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } )
|
|
1490
|
+
y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ),
|
|
1491
|
+
'User' => 'ed', 'Warning' => "A slightly different error message.\n" } )
|
|
1492
|
+
y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ),
|
|
1493
|
+
'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n",
|
|
1494
|
+
'Stack' => [
|
|
1495
|
+
{ 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" },
|
|
1496
|
+
{ 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } )
|
|
1497
|
+
syck: |
|
|
1498
|
+
struct test_node map1[] = {
|
|
1499
|
+
{ T_STR, 0, "Time" },
|
|
1500
|
+
{ T_STR, 0, "2001-11-23 15:01:42 -05:00" },
|
|
1501
|
+
{ T_STR, 0, "User" },
|
|
1502
|
+
{ T_STR, 0, "ed" },
|
|
1503
|
+
{ T_STR, 0, "Warning" },
|
|
1504
|
+
{ T_STR, 0, "This is an error message for the log file\n" },
|
|
1505
|
+
end_node
|
|
1506
|
+
};
|
|
1507
|
+
struct test_node map2[] = {
|
|
1508
|
+
{ T_STR, 0, "Time" },
|
|
1509
|
+
{ T_STR, 0, "2001-11-23 15:02:31 -05:00" },
|
|
1510
|
+
{ T_STR, 0, "User" },
|
|
1511
|
+
{ T_STR, 0, "ed" },
|
|
1512
|
+
{ T_STR, 0, "Warning" },
|
|
1513
|
+
{ T_STR, 0, "A slightly different error message.\n" },
|
|
1514
|
+
end_node
|
|
1515
|
+
};
|
|
1516
|
+
struct test_node file1[] = {
|
|
1517
|
+
{ T_STR, 0, "file" },
|
|
1518
|
+
{ T_STR, 0, "TopClass.py" },
|
|
1519
|
+
{ T_STR, 0, "line" },
|
|
1520
|
+
{ T_STR, 0, "23" },
|
|
1521
|
+
{ T_STR, 0, "code" },
|
|
1522
|
+
{ T_STR, 0, "x = MoreObject(\"345\\n\")\n" },
|
|
1523
|
+
end_node
|
|
1524
|
+
};
|
|
1525
|
+
struct test_node file2[] = {
|
|
1526
|
+
{ T_STR, 0, "file" },
|
|
1527
|
+
{ T_STR, 0, "MoreClass.py" },
|
|
1528
|
+
{ T_STR, 0, "line" },
|
|
1529
|
+
{ T_STR, 0, "58" },
|
|
1530
|
+
{ T_STR, 0, "code" },
|
|
1531
|
+
{ T_STR, 0, "foo = bar" },
|
|
1532
|
+
end_node
|
|
1533
|
+
};
|
|
1534
|
+
struct test_node stack[] = {
|
|
1535
|
+
{ T_MAP, 0, 0, file1 },
|
|
1536
|
+
{ T_MAP, 0, 0, file2 },
|
|
1537
|
+
end_node
|
|
1538
|
+
};
|
|
1539
|
+
struct test_node map3[] = {
|
|
1540
|
+
{ T_STR, 0, "Date" },
|
|
1541
|
+
{ T_STR, 0, "2001-11-23 15:03:17 -05:00" },
|
|
1542
|
+
{ T_STR, 0, "User" },
|
|
1543
|
+
{ T_STR, 0, "ed" },
|
|
1544
|
+
{ T_STR, 0, "Fatal" },
|
|
1545
|
+
{ T_STR, 0, "Unknown variable \"bar\"\n" },
|
|
1546
|
+
{ T_STR, 0, "Stack" },
|
|
1547
|
+
{ T_SEQ, 0, 0, stack },
|
|
1548
|
+
end_node
|
|
1549
|
+
};
|
|
1550
|
+
struct test_node stream[] = {
|
|
1551
|
+
{ T_MAP, 0, 0, map1 },
|
|
1552
|
+
{ T_MAP, 0, 0, map2 },
|
|
1553
|
+
{ T_MAP, 0, 0, map3 },
|
|
1554
|
+
end_node
|
|
1555
|
+
};
|
|
1556
|
+
documents: 3
|
|
1557
|
+
|
|
1558
|
+
---
|
|
1559
|
+
test: Throwaway comments
|
|
1560
|
+
yaml: |
|
|
1561
|
+
### These are four throwaway comment ###
|
|
1562
|
+
|
|
1563
|
+
### lines (the second line is empty). ###
|
|
1564
|
+
this: | # Comments may trail lines.
|
|
1565
|
+
contains three lines of text.
|
|
1566
|
+
The third one starts with a
|
|
1567
|
+
# character. This isn't a comment.
|
|
1568
|
+
|
|
1569
|
+
# These are three throwaway comment
|
|
1570
|
+
# lines (the first line is empty).
|
|
1571
|
+
ruby: |
|
|
1572
|
+
{
|
|
1573
|
+
'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
|
|
1574
|
+
}
|
|
1575
|
+
syck: |
|
|
1576
|
+
struct test_node map[] = {
|
|
1577
|
+
{ T_STR, 0, "this" },
|
|
1578
|
+
{ T_STR, 0, "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n" },
|
|
1579
|
+
end_node
|
|
1580
|
+
};
|
|
1581
|
+
struct test_node stream[] = {
|
|
1582
|
+
{ T_MAP, 0, 0, map },
|
|
1583
|
+
end_node
|
|
1584
|
+
};
|
|
1585
|
+
|
|
1586
|
+
---
|
|
1587
|
+
test: Document with a single value
|
|
1588
|
+
yaml: |
|
|
1589
|
+
--- >
|
|
1590
|
+
This YAML stream contains a single text value.
|
|
1591
|
+
The next stream is a log file - a sequence of
|
|
1592
|
+
log entries. Adding an entry to the log is a
|
|
1593
|
+
simple matter of appending it at the end.
|
|
1594
|
+
ruby: |
|
|
1595
|
+
"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"
|
|
1596
|
+
syck: |
|
|
1597
|
+
struct test_node stream[] = {
|
|
1598
|
+
{ T_STR, 0, "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" },
|
|
1599
|
+
end_node
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
---
|
|
1603
|
+
test: Document stream
|
|
1604
|
+
yaml: |
|
|
1605
|
+
---
|
|
1606
|
+
at: 2001-08-12 09:25:00.00 Z
|
|
1607
|
+
type: GET
|
|
1608
|
+
HTTP: '1.0'
|
|
1609
|
+
url: '/index.html'
|
|
1610
|
+
---
|
|
1611
|
+
at: 2001-08-12 09:25:10.00 Z
|
|
1612
|
+
type: GET
|
|
1613
|
+
HTTP: '1.0'
|
|
1614
|
+
url: '/toc.html'
|
|
1615
|
+
ruby: |
|
|
1616
|
+
y = YAML::Stream.new
|
|
1617
|
+
y.add( {
|
|
1618
|
+
'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ),
|
|
1619
|
+
'type' => 'GET',
|
|
1620
|
+
'HTTP' => '1.0',
|
|
1621
|
+
'url' => '/index.html'
|
|
1622
|
+
} )
|
|
1623
|
+
y.add( {
|
|
1624
|
+
'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ),
|
|
1625
|
+
'type' => 'GET',
|
|
1626
|
+
'HTTP' => '1.0',
|
|
1627
|
+
'url' => '/toc.html'
|
|
1628
|
+
} )
|
|
1629
|
+
syck: |
|
|
1630
|
+
struct test_node map1[] = {
|
|
1631
|
+
{ T_STR, 0, "at" },
|
|
1632
|
+
{ T_STR, 0, "2001-08-12 09:25:00.00 Z" },
|
|
1633
|
+
{ T_STR, 0, "type" },
|
|
1634
|
+
{ T_STR, 0, "GET" },
|
|
1635
|
+
{ T_STR, 0, "HTTP" },
|
|
1636
|
+
{ T_STR, 0, "1.0" },
|
|
1637
|
+
{ T_STR, 0, "url" },
|
|
1638
|
+
{ T_STR, 0, "/index.html" },
|
|
1639
|
+
end_node
|
|
1640
|
+
};
|
|
1641
|
+
struct test_node map2[] = {
|
|
1642
|
+
{ T_STR, 0, "at" },
|
|
1643
|
+
{ T_STR, 0, "2001-08-12 09:25:10.00 Z" },
|
|
1644
|
+
{ T_STR, 0, "type" },
|
|
1645
|
+
{ T_STR, 0, "GET" },
|
|
1646
|
+
{ T_STR, 0, "HTTP" },
|
|
1647
|
+
{ T_STR, 0, "1.0" },
|
|
1648
|
+
{ T_STR, 0, "url" },
|
|
1649
|
+
{ T_STR, 0, "/toc.html" },
|
|
1650
|
+
end_node
|
|
1651
|
+
};
|
|
1652
|
+
struct test_node stream[] = {
|
|
1653
|
+
{ T_MAP, 0, 0, map1 },
|
|
1654
|
+
{ T_MAP, 0, 0, map2 },
|
|
1655
|
+
end_node
|
|
1656
|
+
};
|
|
1657
|
+
documents: 2
|
|
1658
|
+
|
|
1659
|
+
---
|
|
1660
|
+
test: Top level mapping
|
|
1661
|
+
yaml: |
|
|
1662
|
+
# This stream is an example of a top-level mapping.
|
|
1663
|
+
invoice : 34843
|
|
1664
|
+
date : 2001-01-23
|
|
1665
|
+
total : 4443.52
|
|
1666
|
+
ruby: |
|
|
1667
|
+
{
|
|
1668
|
+
'invoice' => 34843,
|
|
1669
|
+
'date' => Date.new( 2001, 1, 23 ),
|
|
1670
|
+
'total' => 4443.52
|
|
1671
|
+
}
|
|
1672
|
+
syck: |
|
|
1673
|
+
struct test_node map[] = {
|
|
1674
|
+
{ T_STR, 0, "invoice" },
|
|
1675
|
+
{ T_STR, 0, "34843" },
|
|
1676
|
+
{ T_STR, 0, "date" },
|
|
1677
|
+
{ T_STR, 0, "2001-01-23" },
|
|
1678
|
+
{ T_STR, 0, "total" },
|
|
1679
|
+
{ T_STR, 0, "4443.52" },
|
|
1680
|
+
end_node
|
|
1681
|
+
};
|
|
1682
|
+
struct test_node stream[] = {
|
|
1683
|
+
{ T_MAP, 0, 0, map },
|
|
1684
|
+
end_node
|
|
1685
|
+
};
|
|
1686
|
+
|
|
1687
|
+
---
|
|
1688
|
+
test: Single-line documents
|
|
1689
|
+
yaml: |
|
|
1690
|
+
# The following is a sequence of three documents.
|
|
1691
|
+
# The first contains an empty mapping, the second
|
|
1692
|
+
# an empty sequence, and the last an empty string.
|
|
1693
|
+
--- {}
|
|
1694
|
+
--- [ ]
|
|
1695
|
+
--- ''
|
|
1696
|
+
ruby: |
|
|
1697
|
+
y = YAML::Stream.new
|
|
1698
|
+
y.add( {} )
|
|
1699
|
+
y.add( [] )
|
|
1700
|
+
y.add( '' )
|
|
1701
|
+
syck: |
|
|
1702
|
+
struct test_node map[] = {
|
|
1703
|
+
end_node
|
|
1704
|
+
};
|
|
1705
|
+
struct test_node seq[] = {
|
|
1706
|
+
end_node
|
|
1707
|
+
};
|
|
1708
|
+
struct test_node stream[] = {
|
|
1709
|
+
{ T_MAP, 0, 0, map },
|
|
1710
|
+
{ T_SEQ, 0, 0, seq },
|
|
1711
|
+
{ T_STR, 0, "" },
|
|
1712
|
+
end_node
|
|
1713
|
+
};
|
|
1714
|
+
documents: 3
|
|
1715
|
+
|
|
1716
|
+
---
|
|
1717
|
+
test: Document with pause
|
|
1718
|
+
yaml: |
|
|
1719
|
+
# A communication channel based on a YAML stream.
|
|
1720
|
+
---
|
|
1721
|
+
sent at: 2002-06-06 11:46:25.10 Z
|
|
1722
|
+
payload: Whatever
|
|
1723
|
+
# Receiver can process this as soon as the following is sent:
|
|
1724
|
+
...
|
|
1725
|
+
# Even if the next message is sent long after:
|
|
1726
|
+
---
|
|
1727
|
+
sent at: 2002-06-06 12:05:53.47 Z
|
|
1728
|
+
payload: Whatever
|
|
1729
|
+
...
|
|
1730
|
+
ruby: |
|
|
1731
|
+
y = YAML::Stream.new
|
|
1732
|
+
y.add(
|
|
1733
|
+
{ 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ),
|
|
1734
|
+
'payload' => 'Whatever' }
|
|
1735
|
+
)
|
|
1736
|
+
y.add(
|
|
1737
|
+
{ "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) }
|
|
1738
|
+
)
|
|
1739
|
+
syck: |
|
|
1740
|
+
struct test_node map1[] = {
|
|
1741
|
+
{ T_STR, 0, "sent at" },
|
|
1742
|
+
{ T_STR, 0, "2002-06-06 11:46:25.10 Z" },
|
|
1743
|
+
{ T_STR, 0, "payload" },
|
|
1744
|
+
{ T_STR, 0, "Whatever" },
|
|
1745
|
+
end_node
|
|
1746
|
+
};
|
|
1747
|
+
struct test_node map2[] = {
|
|
1748
|
+
{ T_STR, 0, "sent at" },
|
|
1749
|
+
{ T_STR, 0, "2002-06-06 12:05:53.47 Z" },
|
|
1750
|
+
{ T_STR, 0, "payload" },
|
|
1751
|
+
{ T_STR, 0, "Whatever" },
|
|
1752
|
+
end_node
|
|
1753
|
+
};
|
|
1754
|
+
struct test_node stream[] = {
|
|
1755
|
+
{ T_MAP, 0, 0, map1 },
|
|
1756
|
+
{ T_MAP, 0, 0, map2 },
|
|
1757
|
+
end_node
|
|
1758
|
+
};
|
|
1759
|
+
documents: 2
|
|
1760
|
+
|
|
1761
|
+
---
|
|
1762
|
+
test: Explicit typing
|
|
1763
|
+
yaml: |
|
|
1764
|
+
integer: 12
|
|
1765
|
+
also int: ! "12"
|
|
1766
|
+
string: !str 12
|
|
1767
|
+
ruby: |
|
|
1768
|
+
{ 'integer' => 12, 'also int' => 12, 'string' => '12' }
|
|
1769
|
+
syck: |
|
|
1770
|
+
struct test_node map[] = {
|
|
1771
|
+
{ T_STR, 0, "integer" },
|
|
1772
|
+
{ T_STR, "tag:yaml.org,2002:int", "12" },
|
|
1773
|
+
{ T_STR, 0, "also int" },
|
|
1774
|
+
{ T_STR, "tag:yaml.org,2002:int", "12" },
|
|
1775
|
+
{ T_STR, 0, "string" },
|
|
1776
|
+
{ T_STR, "tag:yaml.org,2002:str", "12" },
|
|
1777
|
+
end_node
|
|
1778
|
+
};
|
|
1779
|
+
struct test_node stream[] = {
|
|
1780
|
+
{ T_MAP, 0, 0, map },
|
|
1781
|
+
end_node
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
---
|
|
1785
|
+
test: Private types
|
|
1786
|
+
yaml: |
|
|
1787
|
+
# Both examples below make use of the 'x-private:ball'
|
|
1788
|
+
# type family URI, but with different semantics.
|
|
1789
|
+
---
|
|
1790
|
+
pool: !!ball
|
|
1791
|
+
number: 8
|
|
1792
|
+
color: black
|
|
1793
|
+
---
|
|
1794
|
+
bearing: !!ball
|
|
1795
|
+
material: steel
|
|
1796
|
+
ruby: |
|
|
1797
|
+
y = YAML::Stream.new
|
|
1798
|
+
y.add( { 'pool' =>
|
|
1799
|
+
YAML::PrivateType.new( 'ball',
|
|
1800
|
+
{ 'number' => 8, 'color' => 'black' } ) }
|
|
1801
|
+
)
|
|
1802
|
+
y.add( { 'bearing' =>
|
|
1803
|
+
YAML::PrivateType.new( 'ball',
|
|
1804
|
+
{ 'material' => 'steel' } ) }
|
|
1805
|
+
)
|
|
1806
|
+
syck: |
|
|
1807
|
+
struct test_node pool[] = {
|
|
1808
|
+
{ T_STR, 0, "number" },
|
|
1809
|
+
{ T_STR, 0, "8" },
|
|
1810
|
+
{ T_STR, 0, "color" },
|
|
1811
|
+
{ T_STR, 0, "black" },
|
|
1812
|
+
end_node
|
|
1813
|
+
};
|
|
1814
|
+
struct test_node map1[] = {
|
|
1815
|
+
{ T_STR, 0, "pool" },
|
|
1816
|
+
{ T_MAP, "x-private:ball", 0, pool },
|
|
1817
|
+
end_node
|
|
1818
|
+
};
|
|
1819
|
+
struct test_node bearing[] = {
|
|
1820
|
+
{ T_STR, 0, "material" },
|
|
1821
|
+
{ T_STR, 0, "steel" },
|
|
1822
|
+
end_node
|
|
1823
|
+
};
|
|
1824
|
+
struct test_node map2[] = {
|
|
1825
|
+
{ T_STR, 0, "bearing" },
|
|
1826
|
+
{ T_MAP, "x-private:ball", 0, bearing },
|
|
1827
|
+
end_node
|
|
1828
|
+
};
|
|
1829
|
+
struct test_node stream[] = {
|
|
1830
|
+
{ T_MAP, 0, 0, map1 },
|
|
1831
|
+
{ T_MAP, 0, 0, map2 },
|
|
1832
|
+
end_node
|
|
1833
|
+
};
|
|
1834
|
+
documents: 2
|
|
1835
|
+
|
|
1836
|
+
---
|
|
1837
|
+
test: Type family under yaml.org
|
|
1838
|
+
yaml: |
|
|
1839
|
+
# The URI is 'tag:yaml.org,2002:str'
|
|
1840
|
+
- !str a Unicode string
|
|
1841
|
+
python: |
|
|
1842
|
+
[ [ 'a Unicode string' ] ]
|
|
1843
|
+
ruby: |
|
|
1844
|
+
[ 'a Unicode string' ]
|
|
1845
|
+
syck: |
|
|
1846
|
+
struct test_node seq[] = {
|
|
1847
|
+
{ T_STR, "tag:yaml.org,2002:str", "a Unicode string" },
|
|
1848
|
+
end_node
|
|
1849
|
+
};
|
|
1850
|
+
struct test_node stream[] = {
|
|
1851
|
+
{ T_SEQ, 0, 0, seq },
|
|
1852
|
+
end_node
|
|
1853
|
+
};
|
|
1854
|
+
|
|
1855
|
+
---
|
|
1856
|
+
test: Type family under perl.yaml.org
|
|
1857
|
+
yaml: |
|
|
1858
|
+
# The URI is 'tag:perl.yaml.org,2002:Text::Tabs'
|
|
1859
|
+
- !perl/Text::Tabs {}
|
|
1860
|
+
ruby: |
|
|
1861
|
+
[ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ]
|
|
1862
|
+
syck: |
|
|
1863
|
+
struct test_node map[] = {
|
|
1864
|
+
end_node
|
|
1865
|
+
};
|
|
1866
|
+
struct test_node seq[] = {
|
|
1867
|
+
{ T_MAP, "tag:perl.yaml.org,2002:Text::Tabs", 0, map },
|
|
1868
|
+
end_node
|
|
1869
|
+
};
|
|
1870
|
+
struct test_node stream[] = {
|
|
1871
|
+
{ T_SEQ, 0, 0, seq },
|
|
1872
|
+
end_node
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
---
|
|
1876
|
+
test: Type family under clarkevans.com
|
|
1877
|
+
yaml: |
|
|
1878
|
+
# The URI is 'tag:clarkevans.com,2003-02:timesheet'
|
|
1879
|
+
- !clarkevans.com,2003-02/timesheet {}
|
|
1880
|
+
ruby: |
|
|
1881
|
+
[ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ]
|
|
1882
|
+
syck: |
|
|
1883
|
+
struct test_node map[] = {
|
|
1884
|
+
end_node
|
|
1885
|
+
};
|
|
1886
|
+
struct test_node seq[] = {
|
|
1887
|
+
{ T_MAP, "tag:clarkevans.com,2003-02:timesheet", 0, map },
|
|
1888
|
+
end_node
|
|
1889
|
+
};
|
|
1890
|
+
struct test_node stream[] = {
|
|
1891
|
+
{ T_SEQ, 0, 0, seq },
|
|
1892
|
+
end_node
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
---
|
|
1896
|
+
test: URI Escaping
|
|
1897
|
+
yaml: |
|
|
1898
|
+
same:
|
|
1899
|
+
- !domain.tld,2002/type\x30 value
|
|
1900
|
+
- !domain.tld,2002/type0 value
|
|
1901
|
+
different: # As far as the YAML parser is concerned
|
|
1902
|
+
- !domain.tld,2002/type%30 value
|
|
1903
|
+
- !domain.tld,2002/type0 value
|
|
1904
|
+
ruby-setup: |
|
|
1905
|
+
YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
|
|
1906
|
+
"ONE: #{val}"
|
|
1907
|
+
}
|
|
1908
|
+
YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
|
|
1909
|
+
"TWO: #{val}"
|
|
1910
|
+
}
|
|
1911
|
+
ruby: |
|
|
1912
|
+
{ 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] }
|
|
1913
|
+
syck: |
|
|
1914
|
+
struct test_node same[] = {
|
|
1915
|
+
{ T_STR, "tag:domain.tld,2002:type0", "value" },
|
|
1916
|
+
{ T_STR, "tag:domain.tld,2002:type0", "value" },
|
|
1917
|
+
end_node
|
|
1918
|
+
};
|
|
1919
|
+
struct test_node diff[] = {
|
|
1920
|
+
{ T_STR, "tag:domain.tld,2002:type%30", "value" },
|
|
1921
|
+
{ T_STR, "tag:domain.tld,2002:type0", "value" },
|
|
1922
|
+
end_node
|
|
1923
|
+
};
|
|
1924
|
+
struct test_node map[] = {
|
|
1925
|
+
{ T_STR, 0, "same" },
|
|
1926
|
+
{ T_SEQ, 0, 0, same },
|
|
1927
|
+
{ T_STR, 0, "different" },
|
|
1928
|
+
{ T_SEQ, 0, 0, diff },
|
|
1929
|
+
end_node
|
|
1930
|
+
};
|
|
1931
|
+
struct test_node stream[] = {
|
|
1932
|
+
{ T_MAP, 0, 0, map },
|
|
1933
|
+
end_node
|
|
1934
|
+
};
|
|
1935
|
+
|
|
1936
|
+
---
|
|
1937
|
+
test: URI Prefixing
|
|
1938
|
+
yaml: |
|
|
1939
|
+
# 'tag:domain.tld,2002:invoice' is some type family.
|
|
1940
|
+
invoice: !domain.tld,2002/^invoice
|
|
1941
|
+
# 'seq' is shorthand for 'tag:yaml.org,2002:seq'.
|
|
1942
|
+
# This does not effect '^customer' below
|
|
1943
|
+
# because it is does not specify a prefix.
|
|
1944
|
+
customers: !seq
|
|
1945
|
+
# '^customer' is shorthand for the full
|
|
1946
|
+
# notation 'tag:domain.tld,2002:customer'.
|
|
1947
|
+
- !^customer
|
|
1948
|
+
given : Chris
|
|
1949
|
+
family : Dumars
|
|
1950
|
+
ruby-setup: |
|
|
1951
|
+
YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val|
|
|
1952
|
+
if val.is_a? ::Hash
|
|
1953
|
+
scheme, domain, type = type.split( /:/, 3 )
|
|
1954
|
+
val['type'] = "domain #{type}"
|
|
1955
|
+
val
|
|
1956
|
+
else
|
|
1957
|
+
raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect
|
|
1958
|
+
end
|
|
1959
|
+
}
|
|
1960
|
+
ruby: |
|
|
1961
|
+
{ "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }
|
|
1962
|
+
|
|
1963
|
+
---
|
|
1964
|
+
test: Overriding anchors
|
|
1965
|
+
yaml: |
|
|
1966
|
+
anchor : &A001 This scalar has an anchor.
|
|
1967
|
+
override : &A001 >
|
|
1968
|
+
The alias node below is a
|
|
1969
|
+
repeated use of this value.
|
|
1970
|
+
alias : *A001
|
|
1971
|
+
ruby: |
|
|
1972
|
+
{ 'anchor' => 'This scalar has an anchor.',
|
|
1973
|
+
'override' => "The alias node below is a repeated use of this value.\n",
|
|
1974
|
+
'alias' => "The alias node below is a repeated use of this value.\n" }
|
|
1975
|
+
syck: |
|
|
1976
|
+
struct test_node map[] = {
|
|
1977
|
+
{ T_STR, 0, "anchor" },
|
|
1978
|
+
{ T_STR, 0, "This scalar has an anchor." },
|
|
1979
|
+
{ T_STR, 0, "override" },
|
|
1980
|
+
{ T_STR, 0, "The alias node below is a repeated use of this value.\n" },
|
|
1981
|
+
{ T_STR, 0, "alias" },
|
|
1982
|
+
{ T_STR, 0, "The alias node below is a repeated use of this value.\n" },
|
|
1983
|
+
end_node
|
|
1984
|
+
};
|
|
1985
|
+
struct test_node stream[] = {
|
|
1986
|
+
{ T_MAP, 0, 0, map },
|
|
1987
|
+
end_node
|
|
1988
|
+
};
|
|
1989
|
+
|
|
1990
|
+
---
|
|
1991
|
+
test: Flow and block formatting
|
|
1992
|
+
yaml: |
|
|
1993
|
+
empty: []
|
|
1994
|
+
flow: [ one, two, three # May span lines,
|
|
1995
|
+
, four, # indentation is
|
|
1996
|
+
five ] # mostly ignored.
|
|
1997
|
+
block:
|
|
1998
|
+
- First item in top sequence
|
|
1999
|
+
-
|
|
2000
|
+
- Subordinate sequence entry
|
|
2001
|
+
- >
|
|
2002
|
+
A folded sequence entry
|
|
2003
|
+
- Sixth item in top sequence
|
|
2004
|
+
ruby: |
|
|
2005
|
+
{ 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ],
|
|
2006
|
+
'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ],
|
|
2007
|
+
"A folded sequence entry\n", 'Sixth item in top sequence' ] }
|
|
2008
|
+
syck: |
|
|
2009
|
+
struct test_node empty[] = {
|
|
2010
|
+
end_node
|
|
2011
|
+
};
|
|
2012
|
+
struct test_node flow[] = {
|
|
2013
|
+
{ T_STR, 0, "one" },
|
|
2014
|
+
{ T_STR, 0, "two" },
|
|
2015
|
+
{ T_STR, 0, "three" },
|
|
2016
|
+
{ T_STR, 0, "four" },
|
|
2017
|
+
{ T_STR, 0, "five" },
|
|
2018
|
+
end_node
|
|
2019
|
+
};
|
|
2020
|
+
struct test_node inblock[] = {
|
|
2021
|
+
{ T_STR, 0, "Subordinate sequence entry" },
|
|
2022
|
+
end_node
|
|
2023
|
+
};
|
|
2024
|
+
struct test_node block[] = {
|
|
2025
|
+
{ T_STR, 0, "First item in top sequence" },
|
|
2026
|
+
{ T_SEQ, 0, 0, inblock },
|
|
2027
|
+
{ T_STR, 0, "A folded sequence entry\n" },
|
|
2028
|
+
{ T_STR, 0, "Sixth item in top sequence" },
|
|
2029
|
+
end_node
|
|
2030
|
+
};
|
|
2031
|
+
struct test_node map[] = {
|
|
2032
|
+
{ T_STR, 0, "empty" },
|
|
2033
|
+
{ T_SEQ, 0, 0, empty },
|
|
2034
|
+
{ T_STR, 0, "flow" },
|
|
2035
|
+
{ T_SEQ, 0, 0, flow },
|
|
2036
|
+
{ T_STR, 0, "block" },
|
|
2037
|
+
{ T_SEQ, 0, 0, block },
|
|
2038
|
+
end_node
|
|
2039
|
+
};
|
|
2040
|
+
struct test_node stream[] = {
|
|
2041
|
+
{ T_MAP, 0, 0, map },
|
|
2042
|
+
end_node
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
---
|
|
2046
|
+
test: Complete mapping test
|
|
2047
|
+
yaml: |
|
|
2048
|
+
empty: {}
|
|
2049
|
+
flow: { one: 1, two: 2 }
|
|
2050
|
+
spanning: { one: 1,
|
|
2051
|
+
two: 2 }
|
|
2052
|
+
block:
|
|
2053
|
+
first : First entry
|
|
2054
|
+
second:
|
|
2055
|
+
key: Subordinate mapping
|
|
2056
|
+
third:
|
|
2057
|
+
- Subordinate sequence
|
|
2058
|
+
- { }
|
|
2059
|
+
- Previous mapping is empty.
|
|
2060
|
+
- A key: value pair in a sequence.
|
|
2061
|
+
A second: key:value pair.
|
|
2062
|
+
- The previous entry is equal to the following one.
|
|
2063
|
+
-
|
|
2064
|
+
A key: value pair in a sequence.
|
|
2065
|
+
A second: key:value pair.
|
|
2066
|
+
!float 12 : This key is a float.
|
|
2067
|
+
? >
|
|
2068
|
+
?
|
|
2069
|
+
: This key had to be protected.
|
|
2070
|
+
"\a" : This key had to be escaped.
|
|
2071
|
+
? >
|
|
2072
|
+
This is a
|
|
2073
|
+
multi-line
|
|
2074
|
+
folded key
|
|
2075
|
+
: Whose value is
|
|
2076
|
+
also multi-line.
|
|
2077
|
+
? this also works as a key
|
|
2078
|
+
: with a value at the next line.
|
|
2079
|
+
?
|
|
2080
|
+
- This key
|
|
2081
|
+
- is a sequence
|
|
2082
|
+
:
|
|
2083
|
+
- With a sequence value.
|
|
2084
|
+
?
|
|
2085
|
+
This: key
|
|
2086
|
+
is a: mapping
|
|
2087
|
+
:
|
|
2088
|
+
with a: mapping value.
|
|
2089
|
+
ruby: |
|
|
2090
|
+
{ 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 },
|
|
2091
|
+
'spanning' => { 'one' => 1, 'two' => 2 },
|
|
2092
|
+
'block' => { 'first' => 'First entry', 'second' =>
|
|
2093
|
+
{ 'key' => 'Subordinate mapping' }, 'third' =>
|
|
2094
|
+
[ 'Subordinate sequence', {}, 'Previous mapping is empty.',
|
|
2095
|
+
{ 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' },
|
|
2096
|
+
'The previous entry is equal to the following one.',
|
|
2097
|
+
{ 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ],
|
|
2098
|
+
12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.',
|
|
2099
|
+
"\a" => 'This key had to be escaped.',
|
|
2100
|
+
"This is a multi-line folded key\n" => "Whose value is also multi-line.",
|
|
2101
|
+
'this also works as a key' => 'with a value at the next line.',
|
|
2102
|
+
[ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } }
|
|
2103
|
+
# Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact
|
|
2104
|
+
obj_y['block'].keys.each { |k|
|
|
2105
|
+
if Hash === k
|
|
2106
|
+
v = obj_y['block'][k]
|
|
2107
|
+
if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.'
|
|
2108
|
+
obj_r['block'][k] = v
|
|
2109
|
+
end
|
|
2110
|
+
end
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
---
|
|
2114
|
+
test: Literal explicit indentation
|
|
2115
|
+
yaml: |
|
|
2116
|
+
# Explicit indentation must
|
|
2117
|
+
# be given in all the three
|
|
2118
|
+
# following cases.
|
|
2119
|
+
leading spaces: |2
|
|
2120
|
+
This value starts with four spaces.
|
|
2121
|
+
|
|
2122
|
+
leading line break: |2
|
|
2123
|
+
|
|
2124
|
+
This value starts with a line break.
|
|
2125
|
+
|
|
2126
|
+
leading comment indicator: |2
|
|
2127
|
+
# first line starts with a
|
|
2128
|
+
# character.
|
|
2129
|
+
|
|
2130
|
+
# Explicit indentation may
|
|
2131
|
+
# also be given when it is
|
|
2132
|
+
# not required.
|
|
2133
|
+
redundant: |2
|
|
2134
|
+
This value is indented 2 spaces.
|
|
2135
|
+
ruby: |
|
|
2136
|
+
{
|
|
2137
|
+
'leading spaces' => " This value starts with four spaces.\n",
|
|
2138
|
+
'leading line break' => "\nThis value starts with a line break.\n",
|
|
2139
|
+
'leading comment indicator' => "# first line starts with a\n# character.\n",
|
|
2140
|
+
'redundant' => "This value is indented 2 spaces.\n"
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
---
|
|
2144
|
+
test: Chomping and keep modifiers
|
|
2145
|
+
yaml: |
|
|
2146
|
+
clipped: |
|
|
2147
|
+
This has one newline.
|
|
2148
|
+
|
|
2149
|
+
same as "clipped" above: "This has one newline.\n"
|
|
2150
|
+
|
|
2151
|
+
stripped: |-
|
|
2152
|
+
This has no newline.
|
|
2153
|
+
|
|
2154
|
+
same as "stripped" above: "This has no newline."
|
|
2155
|
+
|
|
2156
|
+
kept: |+
|
|
2157
|
+
This has two newlines.
|
|
2158
|
+
|
|
2159
|
+
same as "kept" above: "This has two newlines.\n\n"
|
|
2160
|
+
ruby: |
|
|
2161
|
+
{
|
|
2162
|
+
'clipped' => "This has one newline.\n",
|
|
2163
|
+
'same as "clipped" above' => "This has one newline.\n",
|
|
2164
|
+
'stripped' => 'This has no newline.',
|
|
2165
|
+
'same as "stripped" above' => 'This has no newline.',
|
|
2166
|
+
'kept' => "This has two newlines.\n\n",
|
|
2167
|
+
'same as "kept" above' => "This has two newlines.\n\n"
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
---
|
|
2171
|
+
test: Literal combinations
|
|
2172
|
+
yaml: |
|
|
2173
|
+
empty: |
|
|
2174
|
+
|
|
2175
|
+
literal: |
|
|
2176
|
+
The \ ' " characters may be
|
|
2177
|
+
freely used. Leading white
|
|
2178
|
+
space is significant.
|
|
2179
|
+
|
|
2180
|
+
Line breaks are significant.
|
|
2181
|
+
Thus this value contains one
|
|
2182
|
+
empty line and ends with a
|
|
2183
|
+
single line break, but does
|
|
2184
|
+
not start with one.
|
|
2185
|
+
|
|
2186
|
+
is equal to: "The \\ ' \" characters may \
|
|
2187
|
+
be\nfreely used. Leading white\n space \
|
|
2188
|
+
is significant.\n\nLine breaks are \
|
|
2189
|
+
significant.\nThus this value contains \
|
|
2190
|
+
one\nempty line and ends with a\nsingle \
|
|
2191
|
+
line break, but does\nnot start with one.\n"
|
|
2192
|
+
|
|
2193
|
+
# Comments may follow a block
|
|
2194
|
+
# scalar value. They must be
|
|
2195
|
+
# less indented.
|
|
2196
|
+
|
|
2197
|
+
# Modifiers may be combined in any order.
|
|
2198
|
+
indented and chomped: |2-
|
|
2199
|
+
This has no newline.
|
|
2200
|
+
|
|
2201
|
+
also written as: |-2
|
|
2202
|
+
This has no newline.
|
|
2203
|
+
|
|
2204
|
+
both are equal to: " This has no newline."
|
|
2205
|
+
ruby: |
|
|
2206
|
+
{
|
|
2207
|
+
'empty' => '',
|
|
2208
|
+
'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
|
|
2209
|
+
"is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
|
|
2210
|
+
"empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
|
|
2211
|
+
'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
|
|
2212
|
+
"is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
|
|
2213
|
+
"empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
|
|
2214
|
+
'indented and chomped' => ' This has no newline.',
|
|
2215
|
+
'also written as' => ' This has no newline.',
|
|
2216
|
+
'both are equal to' => ' This has no newline.'
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
---
|
|
2220
|
+
test: Folded combinations
|
|
2221
|
+
yaml: |
|
|
2222
|
+
empty: >
|
|
2223
|
+
|
|
2224
|
+
one paragraph: >
|
|
2225
|
+
Line feeds are converted
|
|
2226
|
+
to spaces, so this value
|
|
2227
|
+
contains no line breaks
|
|
2228
|
+
except for the final one.
|
|
2229
|
+
|
|
2230
|
+
multiple paragraphs: >2
|
|
2231
|
+
|
|
2232
|
+
An empty line, either
|
|
2233
|
+
at the start or in
|
|
2234
|
+
the value:
|
|
2235
|
+
|
|
2236
|
+
Is interpreted as a
|
|
2237
|
+
line break. Thus this
|
|
2238
|
+
value contains three
|
|
2239
|
+
line breaks.
|
|
2240
|
+
|
|
2241
|
+
indented text: >
|
|
2242
|
+
This is a folded
|
|
2243
|
+
paragraph followed
|
|
2244
|
+
by a list:
|
|
2245
|
+
* first entry
|
|
2246
|
+
* second entry
|
|
2247
|
+
Followed by another
|
|
2248
|
+
folded paragraph,
|
|
2249
|
+
another list:
|
|
2250
|
+
|
|
2251
|
+
* first entry
|
|
2252
|
+
|
|
2253
|
+
* second entry
|
|
2254
|
+
|
|
2255
|
+
And a final folded
|
|
2256
|
+
paragraph.
|
|
2257
|
+
|
|
2258
|
+
above is equal to: |
|
|
2259
|
+
This is a folded paragraph followed by a list:
|
|
2260
|
+
* first entry
|
|
2261
|
+
* second entry
|
|
2262
|
+
Followed by another folded paragraph, another list:
|
|
2263
|
+
|
|
2264
|
+
* first entry
|
|
2265
|
+
|
|
2266
|
+
* second entry
|
|
2267
|
+
|
|
2268
|
+
And a final folded paragraph.
|
|
2269
|
+
|
|
2270
|
+
# Explicit comments may follow
|
|
2271
|
+
# but must be less indented.
|
|
2272
|
+
ruby: |
|
|
2273
|
+
{
|
|
2274
|
+
'empty' => '',
|
|
2275
|
+
'one paragraph' => 'Line feeds are converted to spaces, so this value' +
|
|
2276
|
+
" contains no line breaks except for the final one.\n",
|
|
2277
|
+
'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n" +
|
|
2278
|
+
"Is interpreted as a line break. Thus this value contains three line breaks.\n",
|
|
2279
|
+
'indented text' => "This is a folded paragraph followed by a list:\n" +
|
|
2280
|
+
" * first entry\n * second entry\nFollowed by another folded paragraph, " +
|
|
2281
|
+
"another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n",
|
|
2282
|
+
'above is equal to' => "This is a folded paragraph followed by a list:\n" +
|
|
2283
|
+
" * first entry\n * second entry\nFollowed by another folded paragraph, " +
|
|
2284
|
+
"another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
---
|
|
2288
|
+
test: Single quotes
|
|
2289
|
+
yaml: |
|
|
2290
|
+
empty: ''
|
|
2291
|
+
second: '! : \ etc. can be used freely.'
|
|
2292
|
+
third: 'a single quote '' must be escaped.'
|
|
2293
|
+
span: 'this contains
|
|
2294
|
+
six spaces
|
|
2295
|
+
|
|
2296
|
+
and one
|
|
2297
|
+
line break'
|
|
2298
|
+
is same as: "this contains six spaces\nand one line break"
|
|
2299
|
+
ruby: |
|
|
2300
|
+
{
|
|
2301
|
+
'empty' => '',
|
|
2302
|
+
'second' => '! : \\ etc. can be used freely.',
|
|
2303
|
+
'third' => "a single quote ' must be escaped.",
|
|
2304
|
+
'span' => "this contains six spaces\nand one line break",
|
|
2305
|
+
'is same as' => "this contains six spaces\nand one line break"
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
---
|
|
2309
|
+
test: Double quotes
|
|
2310
|
+
yaml: |
|
|
2311
|
+
empty: ""
|
|
2312
|
+
second: "! : etc. can be used freely."
|
|
2313
|
+
third: "a \" or a \\ must be escaped."
|
|
2314
|
+
fourth: "this value ends with an LF.\n"
|
|
2315
|
+
span: "this contains
|
|
2316
|
+
four \
|
|
2317
|
+
spaces"
|
|
2318
|
+
is equal to: "this contains four spaces"
|
|
2319
|
+
ruby: |
|
|
2320
|
+
{
|
|
2321
|
+
'empty' => '',
|
|
2322
|
+
'second' => '! : etc. can be used freely.',
|
|
2323
|
+
'third' => 'a " or a \\ must be escaped.',
|
|
2324
|
+
'fourth' => "this value ends with an LF.\n",
|
|
2325
|
+
'span' => "this contains four spaces",
|
|
2326
|
+
'is equal to' => "this contains four spaces"
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
---
|
|
2330
|
+
test: Unquoted strings
|
|
2331
|
+
yaml: |
|
|
2332
|
+
first: There is no unquoted empty string.
|
|
2333
|
+
|
|
2334
|
+
second: 12 ## This is an integer.
|
|
2335
|
+
|
|
2336
|
+
third: !str 12 ## This is a string.
|
|
2337
|
+
|
|
2338
|
+
span: this contains
|
|
2339
|
+
six spaces
|
|
2340
|
+
|
|
2341
|
+
and one
|
|
2342
|
+
line break
|
|
2343
|
+
|
|
2344
|
+
indicators: this has no comments.
|
|
2345
|
+
#:foo and bar# are
|
|
2346
|
+
both text.
|
|
2347
|
+
|
|
2348
|
+
flow: [ can span
|
|
2349
|
+
lines, # comment
|
|
2350
|
+
like
|
|
2351
|
+
this ]
|
|
2352
|
+
|
|
2353
|
+
note: { one-line keys: but multi-line values }
|
|
2354
|
+
|
|
2355
|
+
ruby: |
|
|
2356
|
+
{
|
|
2357
|
+
'first' => 'There is no unquoted empty string.',
|
|
2358
|
+
'second' => 12,
|
|
2359
|
+
'third' => '12',
|
|
2360
|
+
'span' => "this contains six spaces\nand one line break",
|
|
2361
|
+
'indicators' => "this has no comments. #:foo and bar# are both text.",
|
|
2362
|
+
'flow' => [ 'can span lines', 'like this' ],
|
|
2363
|
+
'note' => { 'one-line keys' => 'but multi-line values' }
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
---
|
|
2367
|
+
test: Spanning sequences
|
|
2368
|
+
yaml: |
|
|
2369
|
+
# The following are equal seqs
|
|
2370
|
+
# with different identities.
|
|
2371
|
+
flow: [ one, two ]
|
|
2372
|
+
spanning: [ one,
|
|
2373
|
+
two ]
|
|
2374
|
+
block:
|
|
2375
|
+
- one
|
|
2376
|
+
- two
|
|
2377
|
+
ruby: |
|
|
2378
|
+
{
|
|
2379
|
+
'flow' => [ 'one', 'two' ],
|
|
2380
|
+
'spanning' => [ 'one', 'two' ],
|
|
2381
|
+
'block' => [ 'one', 'two' ]
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
---
|
|
2385
|
+
test: Flow mappings
|
|
2386
|
+
yaml: |
|
|
2387
|
+
# The following are equal maps
|
|
2388
|
+
# with different identities.
|
|
2389
|
+
flow: { one: 1, two: 2 }
|
|
2390
|
+
block:
|
|
2391
|
+
one: 1
|
|
2392
|
+
two: 2
|
|
2393
|
+
ruby: |
|
|
2394
|
+
{
|
|
2395
|
+
'flow' => { 'one' => 1, 'two' => 2 },
|
|
2396
|
+
'block' => { 'one' => 1, 'two' => 2 }
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
---
|
|
2400
|
+
test: Representations of 12
|
|
2401
|
+
yaml: |
|
|
2402
|
+
- 12 # An integer
|
|
2403
|
+
# The following scalars
|
|
2404
|
+
# are loaded to the
|
|
2405
|
+
# string value '1' '2'.
|
|
2406
|
+
- !str 12
|
|
2407
|
+
- '12'
|
|
2408
|
+
- "12"
|
|
2409
|
+
- "\
|
|
2410
|
+
1\
|
|
2411
|
+
2\
|
|
2412
|
+
"
|
|
2413
|
+
# Strings containing paths and regexps can be unquoted:
|
|
2414
|
+
- /foo/bar
|
|
2415
|
+
- d:/foo/bar
|
|
2416
|
+
- foo/bar
|
|
2417
|
+
- /a.*b/
|
|
2418
|
+
ruby: |
|
|
2419
|
+
[ 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' ]
|
|
2420
|
+
|
|
2421
|
+
---
|
|
2422
|
+
test: "Null"
|
|
2423
|
+
yaml: |
|
|
2424
|
+
canonical: ~
|
|
2425
|
+
|
|
2426
|
+
english: null
|
|
2427
|
+
|
|
2428
|
+
# This sequence has five
|
|
2429
|
+
# entries, two with values.
|
|
2430
|
+
sparse:
|
|
2431
|
+
- ~
|
|
2432
|
+
- 2nd entry
|
|
2433
|
+
- Null
|
|
2434
|
+
- 4th entry
|
|
2435
|
+
-
|
|
2436
|
+
|
|
2437
|
+
four: This mapping has five keys,
|
|
2438
|
+
only two with values.
|
|
2439
|
+
|
|
2440
|
+
ruby: |
|
|
2441
|
+
{
|
|
2442
|
+
'canonical' => nil,
|
|
2443
|
+
'english' => nil,
|
|
2444
|
+
'sparse' => [ nil, '2nd entry', nil, '4th entry', nil ],
|
|
2445
|
+
'four' => 'This mapping has five keys, only two with values.'
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
---
|
|
2449
|
+
test: Omap
|
|
2450
|
+
yaml: |
|
|
2451
|
+
# Explicitly typed dictionary.
|
|
2452
|
+
Bestiary: !omap
|
|
2453
|
+
- aardvark: African pig-like ant eater. Ugly.
|
|
2454
|
+
- anteater: South-American ant eater. Two species.
|
|
2455
|
+
- anaconda: South-American constrictor snake. Scary.
|
|
2456
|
+
# Etc.
|
|
2457
|
+
ruby: |
|
|
2458
|
+
{
|
|
2459
|
+
'Bestiary' => YAML::Omap[
|
|
2460
|
+
'aardvark', 'African pig-like ant eater. Ugly.',
|
|
2461
|
+
'anteater', 'South-American ant eater. Two species.',
|
|
2462
|
+
'anaconda', 'South-American constrictor snake. Scary.'
|
|
2463
|
+
]
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
---
|
|
2467
|
+
test: Pairs
|
|
2468
|
+
yaml: |
|
|
2469
|
+
# Explicitly typed pairs.
|
|
2470
|
+
tasks: !pairs
|
|
2471
|
+
- meeting: with team.
|
|
2472
|
+
- meeting: with boss.
|
|
2473
|
+
- break: lunch.
|
|
2474
|
+
- meeting: with client.
|
|
2475
|
+
ruby: |
|
|
2476
|
+
{
|
|
2477
|
+
'tasks' => YAML::Pairs[
|
|
2478
|
+
'meeting', 'with team.',
|
|
2479
|
+
'meeting', 'with boss.',
|
|
2480
|
+
'break', 'lunch.',
|
|
2481
|
+
'meeting', 'with client.'
|
|
2482
|
+
]
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
---
|
|
2486
|
+
test: Set
|
|
2487
|
+
yaml: |
|
|
2488
|
+
# Explicitly typed set.
|
|
2489
|
+
baseball players: !set
|
|
2490
|
+
Mark McGwire:
|
|
2491
|
+
Sammy Sosa:
|
|
2492
|
+
Ken Griffey:
|
|
2493
|
+
ruby: |
|
|
2494
|
+
{
|
|
2495
|
+
'baseball players' => YAML::Set[
|
|
2496
|
+
'Mark McGwire', nil,
|
|
2497
|
+
'Sammy Sosa', nil,
|
|
2498
|
+
'Ken Griffey', nil
|
|
2499
|
+
]
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
---
|
|
2503
|
+
test: Boolean
|
|
2504
|
+
yaml: |
|
|
2505
|
+
false: used as key
|
|
2506
|
+
logical: true
|
|
2507
|
+
answer: no
|
|
2508
|
+
ruby: |
|
|
2509
|
+
{
|
|
2510
|
+
false => 'used as key',
|
|
2511
|
+
'logical' => true,
|
|
2512
|
+
'answer' => false
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
---
|
|
2516
|
+
test: Integer
|
|
2517
|
+
yaml: |
|
|
2518
|
+
canonical: 12345
|
|
2519
|
+
decimal: +12,345
|
|
2520
|
+
octal: 014
|
|
2521
|
+
hexadecimal: 0xC
|
|
2522
|
+
ruby: |
|
|
2523
|
+
{
|
|
2524
|
+
'canonical' => 12345,
|
|
2525
|
+
'decimal' => 12345,
|
|
2526
|
+
'octal' => 12,
|
|
2527
|
+
'hexadecimal' => 12
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
---
|
|
2531
|
+
test: Float
|
|
2532
|
+
yaml: |
|
|
2533
|
+
canonical: 1.23015e+3
|
|
2534
|
+
exponential: 12.3015e+02
|
|
2535
|
+
fixed: 1,230.15
|
|
2536
|
+
negative infinity: -.inf
|
|
2537
|
+
not a number: .NaN
|
|
2538
|
+
ruby: |
|
|
2539
|
+
{
|
|
2540
|
+
'canonical' => 1230.15,
|
|
2541
|
+
'exponential' => 1230.15,
|
|
2542
|
+
'fixed' => 1230.15,
|
|
2543
|
+
'negative infinity' => -1.0/0.0,
|
|
2544
|
+
'not a number' => 0.0/0.0
|
|
2545
|
+
}
|
|
2546
|
+
if obj_y['not a number'].nan? # NaN comparison doesn't work right against 0.0/0.0
|
|
2547
|
+
obj_r['not a number'] = obj_y['not a number']
|
|
2548
|
+
end
|
|
2549
|
+
|
|
2550
|
+
---
|
|
2551
|
+
test: Timestamp
|
|
2552
|
+
yaml: |
|
|
2553
|
+
canonical: 2001-12-15T02:59:43.1Z
|
|
2554
|
+
valid iso8601: 2001-12-14t21:59:43.10-05:00
|
|
2555
|
+
space separated: 2001-12-14 21:59:43.10 -05:00
|
|
2556
|
+
date (noon UTC): 2002-12-14
|
|
2557
|
+
ruby: |
|
|
2558
|
+
{
|
|
2559
|
+
'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
|
|
2560
|
+
'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
|
|
2561
|
+
'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
|
|
2562
|
+
'date (noon UTC)' => Date.new( 2002, 12, 14 )
|
|
2563
|
+
}
|
|
2564
|
+
syck: |
|
|
2565
|
+
struct test_node map[] = {
|
|
2566
|
+
{ T_STR, 0, "canonical" },
|
|
2567
|
+
{ T_STR, 0, "2001-12-15T02:59:43.1Z" },
|
|
2568
|
+
{ T_STR, 0, "valid iso8601" },
|
|
2569
|
+
{ T_STR, 0, "2001-12-14t21:59:43.10-05:00" },
|
|
2570
|
+
{ T_STR, 0, "space separated" },
|
|
2571
|
+
{ T_STR, 0, "2001-12-14 21:59:43.10 -05:00" },
|
|
2572
|
+
{ T_STR, 0, "date (noon UTC)" },
|
|
2573
|
+
{ T_STR, 0, "2002-12-14" },
|
|
2574
|
+
end_node
|
|
2575
|
+
};
|
|
2576
|
+
struct test_node stream[] = {
|
|
2577
|
+
{ T_MAP, 0, 0, map },
|
|
2578
|
+
end_node
|
|
2579
|
+
};
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
---
|
|
2583
|
+
test: Binary
|
|
2584
|
+
yaml: |
|
|
2585
|
+
canonical: !binary "\
|
|
2586
|
+
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
|
|
2587
|
+
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
|
|
2588
|
+
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
|
|
2589
|
+
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
|
|
2590
|
+
base64: !binary |
|
|
2591
|
+
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
|
|
2592
|
+
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
|
|
2593
|
+
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
|
|
2594
|
+
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
|
|
2595
|
+
description: >
|
|
2596
|
+
The binary value above is a tiny arrow
|
|
2597
|
+
encoded as a gif image.
|
|
2598
|
+
ruby-setup: |
|
|
2599
|
+
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;"
|
|
2600
|
+
ruby: |
|
|
2601
|
+
{
|
|
2602
|
+
'canonical' => arrow_gif,
|
|
2603
|
+
'base64' => arrow_gif,
|
|
2604
|
+
'description' => "The binary value above is a tiny arrow encoded as a gif image.\n"
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
---
|
|
2608
|
+
test: Merge key
|
|
2609
|
+
yaml: |
|
|
2610
|
+
---
|
|
2611
|
+
- &CENTER { x: 1, y: 2 }
|
|
2612
|
+
- &LEFT { x: 0, y: 2 }
|
|
2613
|
+
- &BIG { r: 10 }
|
|
2614
|
+
- &SMALL { r: 1 }
|
|
2615
|
+
|
|
2616
|
+
# All the following maps are equal:
|
|
2617
|
+
|
|
2618
|
+
- # Explicit keys
|
|
2619
|
+
x: 1
|
|
2620
|
+
y: 2
|
|
2621
|
+
r: 10
|
|
2622
|
+
label: center/big
|
|
2623
|
+
|
|
2624
|
+
- # Merge one map
|
|
2625
|
+
<< : *CENTER
|
|
2626
|
+
r: 10
|
|
2627
|
+
label: center/big
|
|
2628
|
+
|
|
2629
|
+
- # Merge multiple maps
|
|
2630
|
+
<< : [ *CENTER, *BIG ]
|
|
2631
|
+
label: center/big
|
|
2632
|
+
|
|
2633
|
+
- # Override
|
|
2634
|
+
<< : [ *BIG, *LEFT, *SMALL ]
|
|
2635
|
+
x: 1
|
|
2636
|
+
label: center/big
|
|
2637
|
+
|
|
2638
|
+
ruby-setup: |
|
|
2639
|
+
center = { 'x' => 1, 'y' => 2 }
|
|
2640
|
+
left = { 'x' => 0, 'y' => 2 }
|
|
2641
|
+
big = { 'r' => 10 }
|
|
2642
|
+
small = { 'r' => 1 }
|
|
2643
|
+
node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' }
|
|
2644
|
+
node2 = center.dup
|
|
2645
|
+
node2.update( { 'r' => 10, 'label' => 'center/big' } )
|
|
2646
|
+
node3 = big.dup
|
|
2647
|
+
node3.update( center )
|
|
2648
|
+
node3.update( { 'label' => 'center/big' } )
|
|
2649
|
+
node4 = small.dup
|
|
2650
|
+
node4.update( left )
|
|
2651
|
+
node4.update( big )
|
|
2652
|
+
node4.update( { 'x' => 1, 'label' => 'center/big' } )
|
|
2653
|
+
|
|
2654
|
+
ruby: |
|
|
2655
|
+
[
|
|
2656
|
+
center, left, big, small, node1, node2, node3, node4
|
|
2657
|
+
]
|
|
2658
|
+
|
|
2659
|
+
---
|
|
2660
|
+
test: Default key
|
|
2661
|
+
yaml: |
|
|
2662
|
+
--- # Old schema
|
|
2663
|
+
link with:
|
|
2664
|
+
- library1.dll
|
|
2665
|
+
- library2.dll
|
|
2666
|
+
--- # New schema
|
|
2667
|
+
link with:
|
|
2668
|
+
- = : library1.dll
|
|
2669
|
+
version: 1.2
|
|
2670
|
+
- = : library2.dll
|
|
2671
|
+
version: 2.3
|
|
2672
|
+
ruby: |
|
|
2673
|
+
y = YAML::Stream.new
|
|
2674
|
+
y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } )
|
|
2675
|
+
obj_h = Hash[ 'version' => 1.2 ]
|
|
2676
|
+
obj_h.default = 'library1.dll'
|
|
2677
|
+
obj_h2 = Hash[ 'version' => 2.3 ]
|
|
2678
|
+
obj_h2.default = 'library2.dll'
|
|
2679
|
+
y.add( { 'link with' => [ obj_h, obj_h2 ] } )
|
|
2680
|
+
documents: 2
|
|
2681
|
+
|
|
2682
|
+
---
|
|
2683
|
+
test: Special keys
|
|
2684
|
+
yaml: |
|
|
2685
|
+
"!": These three keys
|
|
2686
|
+
"&": had to be quoted
|
|
2687
|
+
"=": and are normal strings.
|
|
2688
|
+
# NOTE: the following node should NOT be serialized this way.
|
|
2689
|
+
encoded node :
|
|
2690
|
+
!special '!' : '!type'
|
|
2691
|
+
!special|canonical '&' : 12
|
|
2692
|
+
= : value
|
|
2693
|
+
# The proper way to serialize the above node is as follows:
|
|
2694
|
+
node : !!type &12 value
|
|
2695
|
+
ruby: |
|
|
2696
|
+
{ '!' => 'These three keys', '&' => 'had to be quoted',
|
|
2697
|
+
'=' => 'and are normal strings.',
|
|
2698
|
+
'encoded node' => YAML::PrivateType.new( 'type', 'value' ),
|
|
2699
|
+
'node' => YAML::PrivateType.new( 'type', 'value' ) }
|