Debian Codegraph @

internal/libyaml/testdata/serializer.yaml

raw symbols SCIP
1 # Copyright 2025 The go-yaml Project Contributors
2 # SPDX-License-Identifier: Apache-2.0
3
4 # Serializer stage test cases
5 #
6 # Purpose: Tests the Serializer's ability to convert nodes to YAML output
7 #
8 # Test Types:
9 # serialize-scalar - Tests serializing scalar nodes
10 # serialize-collection - Tests serializing maps and sequences
11 # serialize-style - Tests different YAML styles (flow, literal, etc)
12 #
13 # Field Descriptions:
14 # name: Human-readable test name
15 # node: Input node structure to serialize
16 # kind: Node kind (Document, Scalar, Sequence, Mapping)
17 # value: Scalar value
18 # style: Style (Single, Double, Flow, etc.)
19 # content: Child nodes (array of node objects)
20 # indent: Indentation width (2 or 4 spaces)
21 # want: Expected YAML output (literal block scalar)
22
23 - serialize-scalar:
24 name: Plain string
25 node:
26 kind: Document
27 content:
28 - kind: Scalar
29 value: hello
30 want: |
31 hello
32
33 - serialize-scalar:
34 name: Integer
35 node:
36 kind: Document
37 content:
38 - kind: Scalar
39 value: '42'
40 want: |
41 42
42
43 - serialize-scalar:
44 name: Single quoted string
45 node:
46 kind: Document
47 content:
48 - kind: Scalar
49 value: '123'
50 style: Single
51 want: |
52 '123'
53
54 - serialize-scalar:
55 name: Double quoted string
56 node:
57 kind: Document
58 content:
59 - kind: Scalar
60 value: 'hello'
61 style: Double
62 want: |
63 "hello"
64
65 - serialize-collection:
66 name: Sequence
67 node:
68 kind: Document
69 content:
70 - kind: Sequence
71 content:
72 - kind: Scalar
73 value: a
74 - kind: Scalar
75 value: b
76 want: |
77 - a
78 - b
79
80 - serialize-collection:
81 name: Mapping
82 node:
83 kind: Document
84 content:
85 - kind: Mapping
86 content:
87 - kind: Scalar
88 value: key
89 - kind: Scalar
90 value: value
91 want: |
92 key: value
93
94 - serialize-style:
95 name: Flow sequence
96 node:
97 kind: Document
98 content:
99 - kind: Sequence
100 style: Flow
101 content:
102 - kind: Scalar
103 value: a
104 - kind: Scalar
105 value: b
106 want: |
107 [a, b]
108
109 - serialize-style:
110 name: Flow mapping
111 node:
112 kind: Document
113 content:
114 - kind: Mapping
115 style: Flow
116 content:
117 - kind: Scalar
118 value: key
119 - kind: Scalar
120 value: value
121 want: |
122 {key: value}
123
124 - serialize-collection:
125 name: Nested mapping with 2-space indent
126 indent: 2
127 node:
128 kind: Document
129 content:
130 - kind: Mapping
131 content:
132 - kind: Scalar
133 value: outer
134 - kind: Mapping
135 content:
136 - kind: Scalar
137 value: inner
138 - kind: Scalar
139 value: value
140 want: |
141 outer:
142 inner: value
143
144 - serialize-collection:
145 name: Nested mapping with 4-space indent
146 indent: 4
147 node:
148 kind: Document
149 content:
150 - kind: Mapping
151 content:
152 - kind: Scalar
153 value: outer
154 - kind: Mapping
155 content:
156 - kind: Scalar
157 value: inner
158 - kind: Scalar
159 value: value
160 want: |
161 outer:
162 inner: value