Debian Codegraph @

internal/libyaml/testdata/representer.yaml

raw symbols SCIP
1 # Copyright 2025 The go-yaml Project Contributors
2 # SPDX-License-Identifier: Apache-2.0
3
4 # Representer stage test cases
5 #
6 # Purpose: Tests the Representer's ability to convert Go values to YAML nodes
7 # with proper tags and structure.
8 #
9 # Test Types:
10 # represent-scalar - Tests representing basic scalar types
11 # represent-collection - Tests representing maps and sequences
12 #
13 # Field Descriptions:
14 # name: Human-readable test name
15 # from: Input Go value to represent (int, string, bool, float, null, array, map, binary string)
16 # want: Expected node structure after representation
17 # kind: Expected node kind (Scalar, Sequence, Mapping)
18 # tag: Expected YAML tag (e.g., "!!int", "!!str", "!!binary")
19 # value: Expected scalar value (for Scalar nodes)
20 # content: Expected child nodes (array of node objects for Sequence/Mapping nodes)
21
22 - represent-scalar:
23 name: Integer to node
24 from: 42
25 want:
26 kind: Scalar
27 tag: '!!int'
28 value: '42'
29
30 - represent-scalar:
31 name: String to node
32 from: hello
33 want:
34 kind: Scalar
35 tag: '!!str'
36 value: hello
37
38 - represent-scalar:
39 name: Boolean true to node
40 from: true
41 want:
42 kind: Scalar
43 tag: '!!bool'
44 value: 'true'
45
46 - represent-scalar:
47 name: Float to node
48 from: 3.14
49 want:
50 kind: Scalar
51 tag: '!!float'
52 value: '3.14'
53
54 - represent-scalar:
55 name: Null to node
56 from: null
57 want:
58 kind: Scalar
59 tag: '!!null'
60 value: 'null'
61
62 # - represent-scalar:
63 # name: Binary data gets binary tag
64 # from: "\xFF\xFE"
65 # want:
66 # kind: Scalar
67 # tag: '!!binary'
68
69 - represent-collection:
70 name: Slice to sequence node
71 from: [1, 2, 3]
72 want:
73 kind: Sequence
74 tag: '!!seq'
75 content:
76 - kind: Scalar
77 tag: '!!int'
78 value: '1'
79 - kind: Scalar
80 tag: '!!int'
81 value: '2'
82 - kind: Scalar
83 tag: '!!int'
84 value: '3'
85
86 - represent-collection:
87 name: Map to mapping node
88 from: {a: 1}
89 want:
90 kind: Mapping
91 tag: '!!map'
92 content:
93 - kind: Scalar
94 tag: '!!str'
95 value: a
96 - kind: Scalar
97 tag: '!!int'
98 value: '1'