Debian Codegraph @

internal/libyaml/testdata/composer.yaml

raw symbols SCIP
1 # Copyright 2025 The go-yaml Project Contributors
2 # SPDX-License-Identifier: Apache-2.0
3
4 # Composer stage test cases
5 #
6 # Purpose: Tests the Composer's ability to parse YAML and build node trees
7 #
8 # Test Types:
9 # compose-scalar - Tests parsing scalar values
10 # compose-collection - Tests parsing sequences and mappings
11 # compose-style - Tests style detection (flow, literal, folded, quoted)
12 #
13 # Field Descriptions:
14 # name: Human-readable test name
15 # from: Input YAML text to parse (literal block scalar)
16 # want: Expected node structure after parsing
17 # kind: Expected node kind (Scalar, Sequence, Mapping)
18 # tag: Expected YAML tag (only explicit tags; defaults applied by resolver)
19 # value: Expected scalar value (for Scalar nodes)
20 # style: Expected style flags
21 # content: Expected child nodes (array of node objects)
22
23 - compose-scalar:
24 name: Plain string
25 from: |
26 hello
27 want:
28 kind: Scalar
29 value: hello
30
31 - compose-scalar:
32 name: Integer
33 from: |
34 42
35 want:
36 kind: Scalar
37 value: '42'
38
39 - compose-scalar:
40 name: Single quoted string
41 from: |
42 '123'
43 want:
44 kind: Scalar
45 value: '123'
46 style: Single
47
48 - compose-scalar:
49 name: Double quoted string
50 from: |
51 "hello"
52 want:
53 kind: Scalar
54 value: hello
55 style: Double
56
57 - compose-scalar:
58 name: Literal block scalar
59 from: |
60 |
61 line 1
62 line 2
63 want:
64 kind: Scalar
65 value: "line 1\nline 2\n"
66 style: Literal
67
68 - compose-scalar:
69 name: Folded block scalar
70 from: |
71 >
72 line 1
73 line 2
74 want:
75 kind: Scalar
76 value: "line 1 line 2\n"
77 style: Folded
78
79 - compose-collection:
80 name: Block sequence
81 from: |
82 - a
83 - b
84 - c
85 want:
86 kind: Sequence
87 content:
88 - kind: Scalar
89 value: a
90 - kind: Scalar
91 value: b
92 - kind: Scalar
93 value: c
94
95 - compose-collection:
96 name: Block mapping
97 from: |
98 key1: value1
99 key2: value2
100 want:
101 kind: Mapping
102 content:
103 - kind: Scalar
104 value: key1
105 - kind: Scalar
106 value: value1
107 - kind: Scalar
108 value: key2
109 - kind: Scalar
110 value: value2
111
112 - compose-style:
113 name: Flow sequence
114 from: |
115 [a, b, c]
116 want:
117 kind: Sequence
118 style: Flow
119 content:
120 - kind: Scalar
121 value: a
122 - kind: Scalar
123 value: b
124 - kind: Scalar
125 value: c
126
127 - compose-style:
128 name: Flow mapping
129 from: |
130 {key: value}
131 want:
132 kind: Mapping
133 style: Flow
134 content:
135 - kind: Scalar
136 value: key
137 - kind: Scalar
138 value: value
139
140 - compose-collection:
141 name: Nested mapping
142 from: |
143 outer:
144 inner: value
145 want:
146 kind: Mapping
147 content:
148 - kind: Scalar
149 value: outer
150 - kind: Mapping
151 content:
152 - kind: Scalar
153 value: inner
154 - kind: Scalar
155 value: value