Skip to content

Commit

Permalink
Add YAML Test Suite (#541)
Browse files Browse the repository at this point in the history
* add yaml-test-suite

* add threshold to prevent degrade

* remove recursive option from test

* move test file

* fix lint error

* exclude windows
  • Loading branch information
goccy authored Nov 16, 2024
1 parent 69159b3 commit c312882
Show file tree
Hide file tree
Showing 1,031 changed files with 4,129 additions and 1 deletion.
1 change: 0 additions & 1 deletion decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,6 @@ func TestDecoder_AnchorReferenceDirsRecursive(t *testing.T) {
buf := bytes.NewBufferString("a: *a\n")
dec := yaml.NewDecoder(
buf,
yaml.RecursiveDir(true),
yaml.ReferenceDirs("testdata"),
)
var v struct {
Expand Down
6 changes: 6 additions & 0 deletions testdata/yaml-test-suite/aliases-in-block-sequence/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"a",
"b",
"a",
"b"
]
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/aliases-in-block-sequence/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- &a a
- &b b
- *a
- *b
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
? &a a
: &b b
: *a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&a a: &b b
: *a
1 change: 1 addition & 0 deletions testdata/yaml-test-suite/aliases-in-flow-objects/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ &a [a, &b b]: *b, *a : [c, *b, d]}
8 changes: 8 additions & 0 deletions testdata/yaml-test-suite/aliases-in-flow-objects/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
? &a
- a
- &b b
: *b
*a :
- c
- *b
- d
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"a": "b",
"b": "a"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&a a: &b b
*b : *a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&a a: &b b
*b : *a
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/allowed-characters-in-alias/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"a": "scalar a",
"b": "scalar a"
}
2 changes: 2 additions & 0 deletions testdata/yaml-test-suite/allowed-characters-in-alias/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a: &:@*!$"<foo>: scalar a
b: *:@*!$"<foo>:
7 changes: 7 additions & 0 deletions testdata/yaml-test-suite/allowed-characters-in-keys/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~": "safe",
"?foo": "safe question mark",
":foo": "safe colon",
"-foo": "safe dash",
"this is#not": "a comment"
}
5 changes: 5 additions & 0 deletions testdata/yaml-test-suite/allowed-characters-in-keys/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe
?foo: safe question mark
:foo: safe colon
-foo: safe dash
this is#not: a comment
5 changes: 5 additions & 0 deletions testdata/yaml-test-suite/allowed-characters-in-keys/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe
?foo: safe question mark
:foo: safe colon
-foo: safe dash
this is#not: a comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"safe": "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~",
"safe question mark": "?foo",
"safe colon": ":foo",
"safe dash": "-foo"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
safe question mark: ?foo
safe colon: :foo
safe dash: -foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
safe question mark: ?foo
safe colon: :foo
safe dash: -foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo\nbar:baz\tx \\$%^&*()x": 23,
"x\\ny:z\\tx $%^&*()x": 24
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"foo\nbar:baz\tx \\$%^&*()x": 23
'x\ny:z\tx $%^&*()x': 24
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
? "foo\nbar:baz\tx \\$%^&*()x"
: 23
'x\ny:z\tx $%^&*()x': 24
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
key1: &alias value1
&b *alias : value2
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
&anchor - sequence entry
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"seq": [
"a",
"b"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
seq:
&anchor
- a
- b
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
seq: &anchor
- a
- b
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/anchor-for-empty-node/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"a": null,
"b": null
}
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/anchor-for-empty-node/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
a: &anchor
b: *anchor
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/anchor-for-empty-node/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
a: &anchor
b: *anchor
Empty file.
2 changes: 2 additions & 0 deletions testdata/yaml-test-suite/anchor-plus-alias/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
key1: &a value
key2: &b *a
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"key": "value"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
key: &an:chor value
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
key: &an:chor value
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"unicode anchor"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- &😁 unicode anchor
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- &😁 unicode anchor
6 changes: 6 additions & 0 deletions testdata/yaml-test-suite/anchors-and-tags/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"a",
2,
4,
"d"
]
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/anchors-and-tags/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- &a !!str a
- !!int 2
- !!int &c 4
- &d d
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/anchors-and-tags/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- &a !!str a
- !!int 2
- &c !!int 4
- &d d
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/anchors-in-mapping/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"a": "b",
"c": "d"
}
2 changes: 2 additions & 0 deletions testdata/yaml-test-suite/anchors-in-mapping/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&a a: b
c: &d d
12 changes: 12 additions & 0 deletions testdata/yaml-test-suite/anchors-on-empty-scalars/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- &a
- a
-
&a : a
b: &b
-
&c : &a
-
? &d
-
? &e
: &a
7 changes: 7 additions & 0 deletions testdata/yaml-test-suite/anchors-on-empty-scalars/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- &a
- a
- &a : a
b: &b
- &c : &a
- &d :
- &e : &a
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/anchors-with-colon-in-name/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key": "value",
"foo": "key"
}
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/anchors-with-colon-in-name/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&a: key: &a value
foo:
*a:
2 changes: 2 additions & 0 deletions testdata/yaml-test-suite/anchors-with-colon-in-name/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&a: key: &a value
foo: *a:
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/backslashes-in-singlequotes/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo: bar\\": "baz'"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'foo: bar\': baz'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'foo: bar\': baz'
Empty file.
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/bad-indentation-in-mapping-2/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
map:
key1: "quoted1"
key2: "bad indentation"
Empty file.
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/bad-indentation-in-mapping/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
map:
key1: "quoted1"
key2: "bad indentation"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"scalar1"
{
"key": "value"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
scalar1
...
key: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--- scalar1
...
key: value
5 changes: 5 additions & 0 deletions testdata/yaml-test-suite/blank-lines/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"foo": 1,
"bar": 2,
"text": "a\n \nb\n\nc\n\nd\n"
}
12 changes: 12 additions & 0 deletions testdata/yaml-test-suite/blank-lines/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
foo: 1

bar: 2

text: |
a

b

c

d
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/blank-lines/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
foo: 1
bar: 2
text: "a\n \nb\n\nc\n\nd\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
: a
: b
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"a": null,
"b": null,
"c": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
? a
? b
c:
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a:
b:
c:
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"a true": "null d",
"e 42": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
? a
true
: null
d
? e
42
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a true: null d
e 42:
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"key": "value",
"key2": "value2"
},
{
"key3": "value3"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- key: value
key2: value2
-
key3: value3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- key: value
key2: value2
- key3: value3
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/block-scalar-indicator-order/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"explicit indent and chomp",
"chomp and explicit indent"
]
4 changes: 4 additions & 0 deletions testdata/yaml-test-suite/block-scalar-indicator-order/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- |2-
explicit indent and chomp
- |-2
chomp and explicit indent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- |-
explicit indent and chomp
- |-
chomp and explicit indent
1 change: 1 addition & 0 deletions testdata/yaml-test-suite/block-scalar-keep/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"ab\n\n \n"
5 changes: 5 additions & 0 deletions testdata/yaml-test-suite/block-scalar-keep/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--- |+
ab


...
2 changes: 2 additions & 0 deletions testdata/yaml-test-suite/block-scalar-keep/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"ab\n\n \n"
...
1 change: 1 addition & 0 deletions testdata/yaml-test-suite/block-scalar-strip-1-3/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"ab"
5 changes: 5 additions & 0 deletions testdata/yaml-test-suite/block-scalar-strip-1-3/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--- |-
ab


...
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/block-scalar-strip-1-3/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--- |-
ab
...
1 change: 1 addition & 0 deletions testdata/yaml-test-suite/block-scalar-strip/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"ab"
5 changes: 5 additions & 0 deletions testdata/yaml-test-suite/block-scalar-strip/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
|-
ab


...
3 changes: 3 additions & 0 deletions testdata/yaml-test-suite/block-scalar-strip/out.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
|-
ab
...
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
empty block scalar: >



# comment
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
block scalar: >



invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"key": [
"item1",
"item2"
]
}
Loading

0 comments on commit c312882

Please sign in to comment.