Debian Codegraph @

internal/libyaml/testdata/constructor.yaml

raw symbols SCIP
1 # Copyright 2025 The go-yaml Project Contributors
2 # SPDX-License-Identifier: Apache-2.0
3
4 # Data loader test cases for scalar type resolution
5 #
6 # Purpose: Tests the YAML data loader's ability to correctly parse and resolve
7 # different numeric types (positive/negative integers, floats, scientific notation)
8 #
9 # Test Types:
10 # scalar-resolution - Verifies that scalar values are resolved to correct Go types
11
12 - scalar-resolution:
13 name: Positive integer
14 yaml: "42"
15 want: 42
16
17 - scalar-resolution:
18 name: Negative integer
19 yaml: "-42"
20 want: -42
21
22 - scalar-resolution:
23 name: Zero
24 yaml: "0"
25 want: 0
26
27 - scalar-resolution:
28 name: Hex integer lowercase
29 yaml: "0xff"
30 want: 255
31
32 - scalar-resolution:
33 name: Hex integer uppercase
34 yaml: "0XFF"
35 want: 255
36
37 - scalar-resolution:
38 name: Float with decimal point
39 yaml: "3.14"
40 want: 3.14
41
42 - scalar-resolution:
43 name: Negative float
44 yaml: "-2.5"
45 want: -2.5
46
47 - scalar-resolution:
48 name: Float starting with decimal
49 yaml: ".5"
50 want: 0.5
51
52 - scalar-resolution:
53 name: Float with trailing zeros
54 yaml: "1.500"
55 want: 1.5
56
57 - scalar-resolution:
58 name: Boolean true
59 yaml: "true"
60 want: true
61
62 - scalar-resolution:
63 name: Boolean false
64 yaml: "false"
65 want: false
66
67 - scalar-resolution:
68 name: Null keyword
69 yaml: 'null'
70 want: null
71
72 - scalar-resolution:
73 name: String value
74 yaml: "hello"
75 want: 'hello'
76
77 - scalar-resolution:
78 name: String that looks like number but quoted
79 yaml: '"42"'
80 want: '42'
81
82 - scalar-resolution:
83 name: Mapping with numeric values
84 yaml: |
85 int: 42
86 neg: -10
87 float: 3.14
88 want:
89 int: 42
90 neg: -10
91 float: 3.14
92
93 - scalar-resolution:
94 name: Sequence with mixed numeric types
95 yaml: |
96 - 42
97 - -10
98 - 3.14
99 want:
100 - 42
101 - -10
102 - 3.14