Debian Codegraph @

cmd/go-yaml/testdata/output-modes.yaml

raw symbols SCIP
1 # Tests for different output modes: yaml, YAML, json, JSON
2
3 - name: Simple mapping - YAML output
4 text: |
5 foo: bar
6 baz: qux
7 yaml: |
8 baz: qux
9 foo: bar
10 YAML: |
11 foo: bar
12 baz: qux
13 json: |
14 {"baz":"qux","foo":"bar"}
15 JSON: |
16 {
17 "baz": "qux",
18 "foo": "bar"
19 }
20
21 - name: Simple sequence - YAML output
22 text: |
23 - item1
24 - item2
25 - item3
26 yaml: |
27 - item1
28 - item2
29 - item3
30 YAML: |
31 - item1
32 - item2
33 - item3
34 json: |
35 ["item1","item2","item3"]
36 JSON: |
37 [
38 "item1",
39 "item2",
40 "item3"
41 ]
42
43 - name: Nested structure - YAML output
44 text: |
45 users:
46 - name: Alice
47 age: 30
48 - name: Bob
49 age: 25
50 yaml: |
51 users:
52 - age: 30
53 name: Alice
54 - age: 25
55 name: Bob
56 YAML: |
57 users:
58 - name: Alice
59 age: 30
60 - name: Bob
61 age: 25
62 json: |
63 {"users":[{"age":30,"name":"Alice"},{"age":25,"name":"Bob"}]}
64 JSON: |
65 {
66 "users": [
67 {
68 "age": 30,
69 "name": "Alice"
70 },
71 {
72 "age": 25,
73 "name": "Bob"
74 }
75 ]
76 }
77
78 - name: YAML with comments - preserved
79 text: |
80 # This is a head comment
81 key: value # This is a line comment
82 # This is a foot comment
83 yaml: |
84 key: value
85 YAML: |
86 # This is a head comment
87 key: value # This is a line comment
88 # This is a foot comment
89 json: |
90 {"key":"value"}
91 JSON: |
92 {
93 "key": "value"
94 }
95
96 - name: Flow style mapping - preserved
97 text: "{a: 1, b: 2, c: 3}"
98 yaml: |
99 a: 1
100 b: 2
101 c: 3
102 YAML: "{a: 1, b: 2, c: 3}"
103 json: |
104 {"a":1,"b":2,"c":3}
105 JSON: |
106 {
107 "a": 1,
108 "b": 2,
109 "c": 3
110 }
111
112 - name: Quoted strings - preserved
113 text: |
114 single: 'quoted string'
115 double: "quoted string"
116 plain: plain string
117 yaml: |
118 double: quoted string
119 plain: plain string
120 single: quoted string
121 YAML: |
122 single: 'quoted string'
123 double: "quoted string"
124 plain: plain string
125 json: |
126 {"double":"quoted string","plain":"plain string","single":"quoted string"}
127 JSON: |
128 {
129 "double": "quoted string",
130 "plain": "plain string",
131 "single": "quoted string"
132 }
133
134 - name: Literal block scalar - style preserved
135 text: |
136 description: |
137 This is a literal
138 block scalar that
139 preserves newlines.
140 yaml: |
141 description: |
142 This is a literal
143 block scalar that
144 preserves newlines.
145 YAML: |
146 description: |
147 This is a literal
148 block scalar that
149 preserves newlines.
150 json: |
151 {"description":"This is a literal\nblock scalar that\npreserves newlines.\n"}
152 JSON: |
153 {
154 "description": "This is a literal\nblock scalar that\npreserves newlines.\n"
155 }
156
157 - name: Folded block scalar - style preserved
158 text: |
159 description: >
160 This is a folded
161 block scalar that
162 folds newlines.
163 yaml: |
164 description: |
165 This is a folded block scalar that folds newlines.
166 YAML: |
167 description: >
168 This is a folded block scalar that folds newlines.
169 json: |
170 {"description":"This is a folded block scalar that folds newlines.\n"}
171 JSON: |
172 {
173 "description": "This is a folded block scalar that folds newlines.\n"
174 }
175
176 - name: Mixed types
177 text: |
178 string: hello
179 number: 42
180 float: 3.14
181 bool: true
182 null_value: null
183 yaml: |
184 bool: true
185 float: 3.14
186 null_value: null
187 number: 42
188 string: hello
189 YAML: |
190 string: hello
191 number: 42
192 float: 3.14
193 bool: true
194 null_value: null
195 json: |
196 {"bool":true,"float":3.14,"null_value":null,"number":42,"string":"hello"}
197 JSON: |
198 {
199 "bool": true,
200 "float": 3.14,
201 "null_value": null,
202 "number": 42,
203 "string": "hello"
204 }