From 4f1f35928b1452b66026dbcfb02d9770bd59dfe1 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 5 Aug 2021 15:11:06 +0800 Subject: [PATCH] Put the github.com/BurntSushi/toml-test in internal/ The problem is as follows: - BurntSushi/toml is a TOML library. - BurntSushi/toml-test is a generic language-agnostic TOML testing framework that uses this toml library. - toml-test is based on a CLI interface. This works well, but for this library (since it's written in Go) it's actually quite a bit more convenient to integrate this in "go test"; it's more flexible, easier, and gives us stuff like code coverage. - This introduces a bit of a weird dependency scenario: 1. toml depends on toml-test 2. toml-test depends on toml 3. Because toml-test is only referred to from the toml_test package, this should actually be fine (similar to how you can use the _test package to work around other cyclic dependency issues). - For v0.4.0 the dependencies aren't quite "correct"; it depends on toml-test facb9eccd4da, which in turn depends on toml 20a94d639b8e. This isn't *necessarily* a problem as such as this can be resolved, but commit 20a94d639b8e on toml is not referenced at all and orphaned: I updated the tests in sync with the feature I was working on, and then later rebased the lot it never ended up in the master branch All of this happens to work when using the standard proxy.golang.org GOPROXY because it has that commit in the cache, but right not it doesn't work with GOPROXY=direct as that doesn't have any cache (and a private GOPROXY won't either). This should be fixed by just tagging the current master as v0.4.1, as that now refers to toml-test v1.0.0, which refers to toml v0.4.0. I'm not super-happpy with that solution as such, because I can see it break in the future. So instead, just copy the toml-test package to internal/toml-test here to get rid of any cyclic module dependency. More details can be found in https://github.com/BurntSushi/toml-test/issues/74 One downside is that updating this is a bit awkward now. That's okay for the time being and only affects me, and this doesn't need updating all that often anyway. Another downside is: [~c/toml](master)% du -hd1 internal/ 1.7M internal/toml-test 12K internal/tag 1.7M internal/ 1.7M is kind of a lot. But then again, it's required for running the tests, and all of it is actual test cases. They would be in *_test.go files otherwise anyway. The version in the go.mod is updated because without it: [~c/toml](dep)% go test ./... # github.com/BurntSushi/toml/internal/toml-test [github.com/BurntSushi/toml.test] internal/toml-test/runner.go:27:3: go:embed requires go1.16 or later (-lang was set to go1.13; check go.mod) # github.com/BurntSushi/toml/internal/toml-test internal/toml-test/runner.go:27:3: go:embed requires go1.16 or later (-lang was set to go1.13; check go.mod) FAIL github.com/BurntSushi/toml [build failed] ? github.com/BurntSushi/toml/cmd/toml-test-decoder [no test files] ? github.com/BurntSushi/toml/cmd/toml-test-encoder [no test files] ? github.com/BurntSushi/toml/cmd/tomlv [no test files] ? github.com/BurntSushi/toml/internal [no test files] ? github.com/BurntSushi/toml/internal/tag [no test files] It doesn't "see" that these files are protected by a go1.16 build tag. It should still work for older versions of Go though, just running these tests won't, but that was already the case (toml_test.go has a go1.16 build tag). I also had to add a build tag to the Go files in toml-test.go, since it won't be able to find the embed and io/fs imports on older versions of Go. This also adds GOPROXY=direct in the CI. There aren't any dependencies in go.mod now, but this avoids depending on the peculiarities of proxy.golang.org, and is probably a good idea for most Go CIs. --- .github/workflows/test.yml | 1 + go.mod | 4 +- go.sum | 12 - internal/toml-test/.gitignore | 2 + internal/toml-test/.gogo-release | 1 + internal/toml-test/COPYING | 21 + internal/toml-test/README.md | 258 ++++++++++++ internal/toml-test/gen-multi.py | 14 + internal/toml-test/json.go | 265 ++++++++++++ internal/toml-test/runner.go | 393 ++++++++++++++++++ internal/toml-test/tests/.gitattributes | 1 + .../invalid/array/missing-separator.toml | 1 + .../tests/invalid/array/no-close-2.toml | 1 + .../tests/invalid/array/no-close-table-2.toml | 1 + .../tests/invalid/array/no-close-table.toml | 1 + .../tests/invalid/array/no-close.toml | 1 + .../tests/invalid/array/tables-1.toml | 4 + .../tests/invalid/array/tables-2.toml | 10 + .../array/text-after-array-entries.toml | 4 + .../array/text-before-array-separator.toml | 4 + .../tests/invalid/array/text-in-array.toml | 5 + .../tests/invalid/bool/mixed-case.toml | 1 + .../tests/invalid/bool/wrong-case-false.toml | 1 + .../tests/invalid/bool/wrong-case-true.toml | 1 + .../tests/invalid/control/comment-del.toml | 1 + .../tests/invalid/control/comment-lf.toml | 1 + .../tests/invalid/control/comment-null.toml | Bin 0 -> 26 bytes .../tests/invalid/control/comment-us.toml | 1 + .../tests/invalid/control/control.multi | Bin 0 -> 568 bytes .../tests/invalid/control/multi-del.toml | 1 + .../tests/invalid/control/multi-lf.toml | 1 + .../tests/invalid/control/multi-null.toml | Bin 0 -> 25 bytes .../tests/invalid/control/multi-us.toml | 1 + .../tests/invalid/control/rawmulti-del.toml | 1 + .../tests/invalid/control/rawmulti-lf.toml | 1 + .../tests/invalid/control/rawmulti-null.toml | Bin 0 -> 28 bytes .../tests/invalid/control/rawmulti-us.toml | 1 + .../tests/invalid/control/rawstring-del.toml | 1 + .../tests/invalid/control/rawstring-lf.toml | 1 + .../tests/invalid/control/rawstring-null.toml | Bin 0 -> 25 bytes .../tests/invalid/control/rawstring-us.toml | 1 + .../tests/invalid/control/string-bs.toml | 1 + .../tests/invalid/control/string-del.toml | 1 + .../tests/invalid/control/string-lf.toml | 1 + .../tests/invalid/control/string-null.toml | Bin 0 -> 22 bytes .../tests/invalid/control/string-us.toml | 1 + .../invalid/datetime/impossible-date.toml | 1 + .../invalid/datetime/no-leads-with-milli.toml | 1 + .../tests/invalid/datetime/no-leads.toml | 1 + .../tests/invalid/datetime/no-secs.toml | 1 + .../tests/invalid/datetime/no-t.toml | 1 + .../tests/invalid/datetime/trailing-t.toml | 1 + .../invalid/encoding/bad-utf8-at-end.toml | 5 + .../invalid/encoding/bad-utf8-in-comment.toml | 1 + .../invalid/encoding/bad-utf8-in-string.toml | 2 + .../invalid/encoding/bom-not-at-start-1.toml | 1 + .../invalid/encoding/bom-not-at-start-2.toml | 1 + .../tests/invalid/encoding/utf16-bom.toml | Bin 0 -> 38 bytes .../tests/invalid/encoding/utf16.toml | Bin 0 -> 42 bytes .../tests/invalid/float/double-point-1.toml | 1 + .../tests/invalid/float/double-point-2.toml | 1 + .../tests/invalid/float/exp-double-e-1.toml | 1 + .../tests/invalid/float/exp-double-e-2.toml | 1 + .../tests/invalid/float/exp-double-us.toml | 1 + .../tests/invalid/float/exp-leading-us.toml | 1 + .../tests/invalid/float/exp-point-1.toml | 1 + .../tests/invalid/float/exp-point-2.toml | 1 + .../tests/invalid/float/exp-trailing-us.toml | 1 + .../toml-test/tests/invalid/float/float.multi | 40 ++ .../tests/invalid/float/inf-incomplete-1.toml | 1 + .../tests/invalid/float/inf-incomplete-2.toml | 1 + .../tests/invalid/float/inf-incomplete-3.toml | 1 + .../tests/invalid/float/inf_underscore.toml | 1 + .../invalid/float/leading-point-neg.toml | 1 + .../invalid/float/leading-point-plus.toml | 1 + .../tests/invalid/float/leading-point.toml | 1 + .../tests/invalid/float/leading-us.toml | 1 + .../tests/invalid/float/leading-zero-neg.toml | 1 + .../invalid/float/leading-zero-plus.toml | 1 + .../tests/invalid/float/leading-zero.toml | 1 + .../tests/invalid/float/nan-incomplete-1.toml | 1 + .../tests/invalid/float/nan-incomplete-2.toml | 1 + .../tests/invalid/float/nan-incomplete-3.toml | 1 + .../tests/invalid/float/nan_underscore.toml | 1 + .../invalid/float/trailing-point-min.toml | 1 + .../invalid/float/trailing-point-plus.toml | 1 + .../tests/invalid/float/trailing-point.toml | 1 + .../tests/invalid/float/trailing-us.toml | 1 + .../tests/invalid/float/us-after-point.toml | 1 + .../tests/invalid/float/us-before-point.toml | 1 + .../invalid/inline-table/double-comma.toml | 1 + .../tests/invalid/inline-table/empty.toml | 1 + .../invalid/inline-table/linebreak-1.toml | 4 + .../invalid/inline-table/linebreak-2.toml | 2 + .../invalid/inline-table/linebreak-3.toml | 2 + .../invalid/inline-table/linebreak-4.toml | 4 + .../tests/invalid/inline-table/no-comma.toml | 1 + .../invalid/inline-table/trailing-comma.toml | 3 + .../tests/invalid/integer/capital-bin.toml | 1 + .../tests/invalid/integer/capital-hex.toml | 1 + .../tests/invalid/integer/capital-oct.toml | 1 + .../invalid/integer/double-sign-nex.toml | 1 + .../invalid/integer/double-sign-plus.toml | 1 + .../tests/invalid/integer/double-us.toml | 1 + .../tests/invalid/integer/integer.multi | 39 ++ .../tests/invalid/integer/invalid-bin.toml | 1 + .../tests/invalid/integer/invalid-hex.toml | 1 + .../tests/invalid/integer/invalid-oct.toml | 1 + .../tests/invalid/integer/leading-us-bin.toml | 1 + .../tests/invalid/integer/leading-us-hex.toml | 1 + .../tests/invalid/integer/leading-us-oct.toml | 1 + .../tests/invalid/integer/leading-us.toml | 1 + .../tests/invalid/integer/leading-zero-1.toml | 1 + .../tests/invalid/integer/leading-zero-2.toml | 1 + .../invalid/integer/leading-zero-sign-1.toml | 1 + .../invalid/integer/leading-zero-sign-2.toml | 1 + .../tests/invalid/integer/negative-bin.toml | 1 + .../tests/invalid/integer/negative-hex.toml | 1 + .../tests/invalid/integer/negative-oct.toml | 1 + .../tests/invalid/integer/positive-bin.toml | 1 + .../tests/invalid/integer/positive-hex.toml | 1 + .../tests/invalid/integer/positive-oct.toml | 1 + .../invalid/integer/text-after-integer.toml | 1 + .../invalid/integer/trailing-us-bin.toml | 1 + .../invalid/integer/trailing-us-hex.toml | 1 + .../invalid/integer/trailing-us-oct.toml | 1 + .../tests/invalid/integer/trailing-us.toml | 1 + .../tests/invalid/integer/us-after-bin.toml | 1 + .../tests/invalid/integer/us-after-hex.toml | 1 + .../tests/invalid/integer/us-after-oct.toml | 1 + .../tests/invalid/key/after-array.toml | 1 + .../tests/invalid/key/after-table.toml | 1 + .../tests/invalid/key/after-value.toml | 1 + .../invalid/key/bare-invalid-character.toml | 1 + .../invalid/key/dotted-redefine-table.toml | 4 + .../tests/invalid/key/duplicate-keys.toml | 2 + .../tests/invalid/key/duplicate.toml | 3 + .../toml-test/tests/invalid/key/empty.toml | 1 + .../toml-test/tests/invalid/key/escape.toml | 1 + .../toml-test/tests/invalid/key/hash.toml | 1 + .../tests/invalid/key/multiline.toml | 2 + .../toml-test/tests/invalid/key/newline.toml | 2 + .../toml-test/tests/invalid/key/no-eol.toml | 1 + .../tests/invalid/key/open-bracket.toml | 1 + .../tests/invalid/key/partial-quoted.toml | 1 + .../invalid/key/single-open-bracket.toml | 1 + .../toml-test/tests/invalid/key/space.toml | 1 + .../tests/invalid/key/special-character.toml | 1 + .../tests/invalid/key/start-bracket.toml | 3 + .../tests/invalid/key/two-equals.toml | 1 + .../tests/invalid/key/two-equals2.toml | 1 + .../tests/invalid/key/two-equals3.toml | 1 + .../tests/invalid/key/without-value-1.toml | 1 + .../tests/invalid/key/without-value-2.toml | 1 + .../tests/invalid/string/bad-byte-escape.toml | 1 + .../tests/invalid/string/bad-codepoint.toml | 1 + .../tests/invalid/string/bad-concat.toml | 1 + .../tests/invalid/string/bad-escape.toml | 1 + .../tests/invalid/string/bad-multiline.toml | 2 + .../invalid/string/bad-slash-escape.toml | 1 + .../tests/invalid/string/bad-uni-esc.toml | 1 + .../invalid/string/basic-byte-escapes.toml | 1 + ...ltiline-out-of-range-unicode-escape-1.toml | 1 + ...ltiline-out-of-range-unicode-escape-2.toml | 1 + .../string/basic-multiline-quotes.toml | 1 + .../basic-multiline-unknown-escape.toml | 1 + .../basic-out-of-range-unicode-escape-1.toml | 1 + .../basic-out-of-range-unicode-escape-2.toml | 1 + .../invalid/string/basic-unknown-escape.toml | 1 + .../string/literal-multiline-quotes-1.toml | 2 + .../string/literal-multiline-quotes-2.toml | 1 + .../tests/invalid/string/missing-quotes.toml | 1 + .../string/multiline-escape-space.toml | 3 + .../invalid/string/multiline-no-close-2.toml | 1 + .../invalid/string/multiline-no-close.toml | 2 + .../invalid/string/multiline-quotes-1.toml | 1 + .../invalid/string/multiline-quotes-2.toml | 1 + .../tests/invalid/string/no-close.toml | 1 + .../invalid/string/text-after-string.toml | 1 + .../tests/invalid/string/wrong-close.toml | 1 + .../tests/invalid/table/array-empty.toml | 2 + .../tests/invalid/table/array-implicit.toml | 14 + .../invalid/table/array-missing-bracket.toml | 2 + .../invalid/table/duplicate-key-table.toml | 5 + .../invalid/table/duplicate-table-array.toml | 2 + .../invalid/table/duplicate-table-array2.toml | 2 + .../tests/invalid/table/duplicate.toml | 5 + .../invalid/table/empty-implicit-table.toml | 1 + .../toml-test/tests/invalid/table/empty.toml | 1 + .../tests/invalid/table/equals-sign.toml | 1 + .../tests/invalid/table/llbrace.toml | 1 + .../invalid/table/nested-brackets-close.toml | 2 + .../invalid/table/nested-brackets-open.toml | 2 + .../tests/invalid/table/quoted-no-close.toml | 2 + .../tests/invalid/table/redefine.toml | 6 + .../tests/invalid/table/rrbrace.toml | 1 + .../tests/invalid/table/text-after-table.toml | 1 + .../tests/invalid/table/whitespace.toml | 1 + .../tests/invalid/table/with-pound.toml | 2 + .../toml-test/tests/valid/array/array.json | 68 +++ .../toml-test/tests/valid/array/array.toml | 12 + .../toml-test/tests/valid/array/bool.json | 12 + .../toml-test/tests/valid/array/bool.toml | 1 + .../toml-test/tests/valid/array/empty.json | 11 + .../toml-test/tests/valid/array/empty.toml | 1 + .../tests/valid/array/hetergeneous.json | 34 ++ .../tests/valid/array/hetergeneous.toml | 1 + .../tests/valid/array/mixed-int-array.json | 14 + .../tests/valid/array/mixed-int-array.toml | 1 + .../tests/valid/array/mixed-int-float.json | 12 + .../tests/valid/array/mixed-int-float.toml | 1 + .../tests/valid/array/mixed-int-string.json | 12 + .../tests/valid/array/mixed-int-string.toml | 1 + .../tests/valid/array/mixed-string-table.json | 22 + .../tests/valid/array/mixed-string-table.toml | 4 + .../tests/valid/array/nested-double.json | 28 ++ .../tests/valid/array/nested-double.toml | 6 + .../valid/array/nested-inline-table.json | 7 + .../valid/array/nested-inline-table.toml | 1 + .../toml-test/tests/valid/array/nested.json | 16 + .../toml-test/tests/valid/array/nested.toml | 1 + .../toml-test/tests/valid/array/nospaces.json | 16 + .../toml-test/tests/valid/array/nospaces.toml | 1 + .../valid/array/string-quote-comma-2.json | 8 + .../valid/array/string-quote-comma-2.toml | 1 + .../tests/valid/array/string-quote-comma.json | 12 + .../tests/valid/array/string-quote-comma.toml | 4 + .../tests/valid/array/string-with-comma.json | 12 + .../tests/valid/array/string-with-comma.toml | 4 + .../toml-test/tests/valid/array/strings.json | 20 + .../toml-test/tests/valid/array/strings.toml | 1 + .../array/table-array-string-backslash.json | 10 + .../array/table-array-string-backslash.toml | 1 + internal/toml-test/tests/valid/bool/bool.json | 10 + internal/toml-test/tests/valid/bool/bool.toml | 2 + .../toml-test/tests/valid/comment/at-eof.json | 6 + .../toml-test/tests/valid/comment/at-eof.toml | 2 + .../tests/valid/comment/at-eof2.json | 6 + .../tests/valid/comment/at-eof2.toml | 2 + .../tests/valid/comment/everywhere.json | 22 + .../tests/valid/comment/everywhere.toml | 27 ++ .../toml-test/tests/valid/comment/tricky.json | 98 +++++ .../toml-test/tests/valid/comment/tricky.toml | 31 ++ .../tests/valid/datetime/datetime.json | 10 + .../tests/valid/datetime/datetime.toml | 2 + .../tests/valid/datetime/local-date.json | 6 + .../tests/valid/datetime/local-date.toml | 1 + .../tests/valid/datetime/local-time.json | 10 + .../tests/valid/datetime/local-time.toml | 2 + .../toml-test/tests/valid/datetime/local.json | 14 + .../toml-test/tests/valid/datetime/local.toml | 3 + .../tests/valid/datetime/milliseconds.json | 18 + .../tests/valid/datetime/milliseconds.toml | 4 + .../tests/valid/datetime/timezone.json | 18 + .../tests/valid/datetime/timezone.toml | 4 + .../toml-test/tests/valid/empty-file.json | 1 + .../toml-test/tests/valid/empty-file.toml | 0 internal/toml-test/tests/valid/example.json | 26 ++ internal/toml-test/tests/valid/example.toml | 5 + .../toml-test/tests/valid/float/exponent.json | 34 ++ .../toml-test/tests/valid/float/exponent.toml | 8 + .../toml-test/tests/valid/float/float.json | 18 + .../toml-test/tests/valid/float/float.toml | 4 + .../tests/valid/float/inf-and-nan.json | 26 ++ .../tests/valid/float/inf-and-nan.toml | 8 + .../toml-test/tests/valid/float/long.json | 10 + .../toml-test/tests/valid/float/long.toml | 2 + .../tests/valid/float/underscore.json | 14 + .../tests/valid/float/underscore.toml | 3 + .../toml-test/tests/valid/float/zero.json | 30 ++ .../toml-test/tests/valid/float/zero.toml | 7 + .../valid/implicit-and-explicit-after.json | 16 + .../valid/implicit-and-explicit-after.toml | 5 + .../valid/implicit-and-explicit-before.json | 16 + .../valid/implicit-and-explicit-before.toml | 5 + .../tests/valid/implicit-groups.json | 12 + .../tests/valid/implicit-groups.toml | 2 + .../tests/valid/inline-table/array.json | 34 ++ .../tests/valid/inline-table/array.toml | 3 + .../tests/valid/inline-table/bool.json | 12 + .../tests/valid/inline-table/bool.toml | 1 + .../tests/valid/inline-table/empty.json | 30 ++ .../tests/valid/inline-table/empty.toml | 6 + .../tests/valid/inline-table/end-in-bool.json | 16 + .../tests/valid/inline-table/end-in-bool.toml | 1 + .../valid/inline-table/inline-table.json | 48 +++ .../valid/inline-table/inline-table.toml | 5 + .../tests/valid/inline-table/key-dotted.json | 140 +++++++ .../tests/valid/inline-table/key-dotted.toml | 23 + .../tests/valid/inline-table/multiline.json | 20 + .../tests/valid/inline-table/multiline.toml | 4 + .../tests/valid/inline-table/nest.json | 64 +++ .../tests/valid/inline-table/nest.toml | 10 + .../tests/valid/integer/integer.json | 18 + .../tests/valid/integer/integer.toml | 4 + .../tests/valid/integer/literals.json | 38 ++ .../tests/valid/integer/literals.toml | 11 + .../toml-test/tests/valid/integer/long.json | 10 + .../toml-test/tests/valid/integer/long.toml | 2 + .../tests/valid/integer/underscore.json | 10 + .../tests/valid/integer/underscore.toml | 2 + .../toml-test/tests/valid/integer/zero.json | 50 +++ .../toml-test/tests/valid/integer/zero.toml | 15 + .../toml-test/tests/valid/key/alphanum.json | 46 ++ .../toml-test/tests/valid/key/alphanum.toml | 14 + .../tests/valid/key/case-sensitive.json | 38 ++ .../tests/valid/key/case-sensitive.toml | 13 + .../toml-test/tests/valid/key/dotted.json | 132 ++++++ .../toml-test/tests/valid/key/dotted.toml | 35 ++ internal/toml-test/tests/valid/key/empty.json | 6 + internal/toml-test/tests/valid/key/empty.toml | 1 + .../tests/valid/key/equals-nospace.json | 6 + .../tests/valid/key/equals-nospace.toml | 1 + .../toml-test/tests/valid/key/escapes.json | 24 ++ .../toml-test/tests/valid/key/escapes.toml | 10 + .../tests/valid/key/numeric-dotted.json | 8 + .../tests/valid/key/numeric-dotted.toml | 1 + .../toml-test/tests/valid/key/numeric.json | 6 + .../toml-test/tests/valid/key/numeric.toml | 1 + .../tests/valid/key/quoted-dots.json | 32 ++ .../tests/valid/key/quoted-dots.toml | 10 + internal/toml-test/tests/valid/key/space.json | 6 + internal/toml-test/tests/valid/key/space.toml | 1 + .../tests/valid/key/special-chars.json | 6 + .../tests/valid/key/special-chars.toml | 1 + .../tests/valid/key/special-word.json | 18 + .../tests/valid/key/special-word.toml | 5 + .../toml-test/tests/valid/newline-crlf.json | 10 + .../toml-test/tests/valid/newline-crlf.toml | 2 + .../toml-test/tests/valid/newline-lf.json | 10 + .../toml-test/tests/valid/newline-lf.toml | 2 + .../tests/valid/spec-example-1-compact.json | 100 +++++ .../tests/valid/spec-example-1-compact.toml | 23 + .../toml-test/tests/valid/spec-example-1.json | 100 +++++ .../toml-test/tests/valid/spec-example-1.toml | 33 ++ .../valid/string/double-quote-escape.json | 6 + .../valid/string/double-quote-escape.toml | 1 + .../toml-test/tests/valid/string/empty.json | 6 + .../toml-test/tests/valid/string/empty.toml | 1 + .../tests/valid/string/escape-tricky.json | 30 ++ .../tests/valid/string/escape-tricky.toml | 15 + .../tests/valid/string/escaped-escape.json | 6 + .../tests/valid/string/escaped-escape.toml | 1 + .../toml-test/tests/valid/string/escapes.json | 54 +++ .../toml-test/tests/valid/string/escapes.toml | 13 + .../tests/valid/string/multiline-json | 54 +++ .../tests/valid/string/multiline-quotes.json | 42 ++ .../tests/valid/string/multiline-quotes.toml | 15 + .../tests/valid/string/multiline-toml | 46 ++ internal/toml-test/tests/valid/string/nl.json | 22 + internal/toml-test/tests/valid/string/nl.toml | 6 + .../tests/valid/string/raw-multiline.json | 14 + .../tests/valid/string/raw-multiline.toml | 9 + .../toml-test/tests/valid/string/raw.json | 30 ++ .../toml-test/tests/valid/string/raw.toml | 7 + .../toml-test/tests/valid/string/simple.json | 6 + .../toml-test/tests/valid/string/simple.toml | 1 + .../tests/valid/string/unicode-escape.json | 10 + .../tests/valid/string/unicode-escape.toml | 2 + .../tests/valid/string/unicode-literal.json | 6 + .../tests/valid/string/unicode-literal.toml | 1 + .../tests/valid/string/with-pound.json | 10 + .../tests/valid/string/with-pound.toml | 2 + .../tests/valid/table/array-implicit.json | 12 + .../tests/valid/table/array-implicit.toml | 2 + .../tests/valid/table/array-many.json | 34 ++ .../tests/valid/table/array-many.toml | 11 + .../tests/valid/table/array-nest.json | 44 ++ .../tests/valid/table/array-nest.toml | 17 + .../tests/valid/table/array-one.json | 14 + .../tests/valid/table/array-one.toml | 3 + .../tests/valid/table/array-table-array.json | 24 ++ .../tests/valid/table/array-table-array.toml | 7 + .../toml-test/tests/valid/table/empty.json | 3 + .../toml-test/tests/valid/table/empty.toml | 1 + .../toml-test/tests/valid/table/keyword.json | 6 + .../toml-test/tests/valid/table/keyword.toml | 9 + .../toml-test/tests/valid/table/names.json | 30 ++ .../toml-test/tests/valid/table/names.toml | 9 + .../toml-test/tests/valid/table/no-eol.json | 3 + .../toml-test/tests/valid/table/no-eol.toml | 1 + .../tests/valid/table/sub-empty.json | 5 + .../tests/valid/table/sub-empty.toml | 2 + .../tests/valid/table/whitespace.json | 3 + .../tests/valid/table/whitespace.toml | 1 + .../valid/table/with-literal-string.json | 12 + .../valid/table/with-literal-string.toml | 4 + .../tests/valid/table/with-pound.json | 8 + .../tests/valid/table/with-pound.toml | 2 + .../tests/valid/table/with-single-quotes.json | 12 + .../tests/valid/table/with-single-quotes.toml | 4 + .../tests/valid/table/without-super.json | 9 + .../tests/valid/table/without-super.toml | 5 + internal/toml-test/toml.go | 133 ++++++ toml_test.go | 2 +- 395 files changed, 4331 insertions(+), 16 deletions(-) create mode 100644 internal/toml-test/.gitignore create mode 100644 internal/toml-test/.gogo-release create mode 100644 internal/toml-test/COPYING create mode 100644 internal/toml-test/README.md create mode 100644 internal/toml-test/gen-multi.py create mode 100644 internal/toml-test/json.go create mode 100644 internal/toml-test/runner.go create mode 100644 internal/toml-test/tests/.gitattributes create mode 100644 internal/toml-test/tests/invalid/array/missing-separator.toml create mode 100644 internal/toml-test/tests/invalid/array/no-close-2.toml create mode 100644 internal/toml-test/tests/invalid/array/no-close-table-2.toml create mode 100644 internal/toml-test/tests/invalid/array/no-close-table.toml create mode 100644 internal/toml-test/tests/invalid/array/no-close.toml create mode 100644 internal/toml-test/tests/invalid/array/tables-1.toml create mode 100644 internal/toml-test/tests/invalid/array/tables-2.toml create mode 100644 internal/toml-test/tests/invalid/array/text-after-array-entries.toml create mode 100644 internal/toml-test/tests/invalid/array/text-before-array-separator.toml create mode 100644 internal/toml-test/tests/invalid/array/text-in-array.toml create mode 100644 internal/toml-test/tests/invalid/bool/mixed-case.toml create mode 100644 internal/toml-test/tests/invalid/bool/wrong-case-false.toml create mode 100644 internal/toml-test/tests/invalid/bool/wrong-case-true.toml create mode 100644 internal/toml-test/tests/invalid/control/comment-del.toml create mode 100644 internal/toml-test/tests/invalid/control/comment-lf.toml create mode 100644 internal/toml-test/tests/invalid/control/comment-null.toml create mode 100644 internal/toml-test/tests/invalid/control/comment-us.toml create mode 100644 internal/toml-test/tests/invalid/control/control.multi create mode 100644 internal/toml-test/tests/invalid/control/multi-del.toml create mode 100644 internal/toml-test/tests/invalid/control/multi-lf.toml create mode 100644 internal/toml-test/tests/invalid/control/multi-null.toml create mode 100644 internal/toml-test/tests/invalid/control/multi-us.toml create mode 100644 internal/toml-test/tests/invalid/control/rawmulti-del.toml create mode 100644 internal/toml-test/tests/invalid/control/rawmulti-lf.toml create mode 100644 internal/toml-test/tests/invalid/control/rawmulti-null.toml create mode 100644 internal/toml-test/tests/invalid/control/rawmulti-us.toml create mode 100644 internal/toml-test/tests/invalid/control/rawstring-del.toml create mode 100644 internal/toml-test/tests/invalid/control/rawstring-lf.toml create mode 100644 internal/toml-test/tests/invalid/control/rawstring-null.toml create mode 100644 internal/toml-test/tests/invalid/control/rawstring-us.toml create mode 100644 internal/toml-test/tests/invalid/control/string-bs.toml create mode 100644 internal/toml-test/tests/invalid/control/string-del.toml create mode 100644 internal/toml-test/tests/invalid/control/string-lf.toml create mode 100644 internal/toml-test/tests/invalid/control/string-null.toml create mode 100644 internal/toml-test/tests/invalid/control/string-us.toml create mode 100644 internal/toml-test/tests/invalid/datetime/impossible-date.toml create mode 100644 internal/toml-test/tests/invalid/datetime/no-leads-with-milli.toml create mode 100644 internal/toml-test/tests/invalid/datetime/no-leads.toml create mode 100644 internal/toml-test/tests/invalid/datetime/no-secs.toml create mode 100644 internal/toml-test/tests/invalid/datetime/no-t.toml create mode 100644 internal/toml-test/tests/invalid/datetime/trailing-t.toml create mode 100644 internal/toml-test/tests/invalid/encoding/bad-utf8-at-end.toml create mode 100644 internal/toml-test/tests/invalid/encoding/bad-utf8-in-comment.toml create mode 100644 internal/toml-test/tests/invalid/encoding/bad-utf8-in-string.toml create mode 100644 internal/toml-test/tests/invalid/encoding/bom-not-at-start-1.toml create mode 100644 internal/toml-test/tests/invalid/encoding/bom-not-at-start-2.toml create mode 100644 internal/toml-test/tests/invalid/encoding/utf16-bom.toml create mode 100644 internal/toml-test/tests/invalid/encoding/utf16.toml create mode 100644 internal/toml-test/tests/invalid/float/double-point-1.toml create mode 100644 internal/toml-test/tests/invalid/float/double-point-2.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-double-e-1.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-double-e-2.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-double-us.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-leading-us.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-point-1.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-point-2.toml create mode 100644 internal/toml-test/tests/invalid/float/exp-trailing-us.toml create mode 100644 internal/toml-test/tests/invalid/float/float.multi create mode 100644 internal/toml-test/tests/invalid/float/inf-incomplete-1.toml create mode 100644 internal/toml-test/tests/invalid/float/inf-incomplete-2.toml create mode 100644 internal/toml-test/tests/invalid/float/inf-incomplete-3.toml create mode 100644 internal/toml-test/tests/invalid/float/inf_underscore.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-point-neg.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-point-plus.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-point.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-us.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-zero-neg.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-zero-plus.toml create mode 100644 internal/toml-test/tests/invalid/float/leading-zero.toml create mode 100644 internal/toml-test/tests/invalid/float/nan-incomplete-1.toml create mode 100644 internal/toml-test/tests/invalid/float/nan-incomplete-2.toml create mode 100644 internal/toml-test/tests/invalid/float/nan-incomplete-3.toml create mode 100644 internal/toml-test/tests/invalid/float/nan_underscore.toml create mode 100644 internal/toml-test/tests/invalid/float/trailing-point-min.toml create mode 100644 internal/toml-test/tests/invalid/float/trailing-point-plus.toml create mode 100644 internal/toml-test/tests/invalid/float/trailing-point.toml create mode 100644 internal/toml-test/tests/invalid/float/trailing-us.toml create mode 100644 internal/toml-test/tests/invalid/float/us-after-point.toml create mode 100644 internal/toml-test/tests/invalid/float/us-before-point.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/double-comma.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/empty.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/linebreak-1.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/linebreak-2.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/linebreak-3.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/linebreak-4.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/no-comma.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/trailing-comma.toml create mode 100644 internal/toml-test/tests/invalid/integer/capital-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/capital-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/capital-oct.toml create mode 100644 internal/toml-test/tests/invalid/integer/double-sign-nex.toml create mode 100644 internal/toml-test/tests/invalid/integer/double-sign-plus.toml create mode 100644 internal/toml-test/tests/invalid/integer/double-us.toml create mode 100644 internal/toml-test/tests/invalid/integer/integer.multi create mode 100644 internal/toml-test/tests/invalid/integer/invalid-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/invalid-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/invalid-oct.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-us-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-us-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-us-oct.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-us.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-zero-1.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-zero-2.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-zero-sign-1.toml create mode 100644 internal/toml-test/tests/invalid/integer/leading-zero-sign-2.toml create mode 100644 internal/toml-test/tests/invalid/integer/negative-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/negative-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/negative-oct.toml create mode 100644 internal/toml-test/tests/invalid/integer/positive-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/positive-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/positive-oct.toml create mode 100644 internal/toml-test/tests/invalid/integer/text-after-integer.toml create mode 100644 internal/toml-test/tests/invalid/integer/trailing-us-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/trailing-us-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/trailing-us-oct.toml create mode 100644 internal/toml-test/tests/invalid/integer/trailing-us.toml create mode 100644 internal/toml-test/tests/invalid/integer/us-after-bin.toml create mode 100644 internal/toml-test/tests/invalid/integer/us-after-hex.toml create mode 100644 internal/toml-test/tests/invalid/integer/us-after-oct.toml create mode 100644 internal/toml-test/tests/invalid/key/after-array.toml create mode 100644 internal/toml-test/tests/invalid/key/after-table.toml create mode 100644 internal/toml-test/tests/invalid/key/after-value.toml create mode 100644 internal/toml-test/tests/invalid/key/bare-invalid-character.toml create mode 100644 internal/toml-test/tests/invalid/key/dotted-redefine-table.toml create mode 100644 internal/toml-test/tests/invalid/key/duplicate-keys.toml create mode 100644 internal/toml-test/tests/invalid/key/duplicate.toml create mode 100644 internal/toml-test/tests/invalid/key/empty.toml create mode 100644 internal/toml-test/tests/invalid/key/escape.toml create mode 100644 internal/toml-test/tests/invalid/key/hash.toml create mode 100644 internal/toml-test/tests/invalid/key/multiline.toml create mode 100644 internal/toml-test/tests/invalid/key/newline.toml create mode 100644 internal/toml-test/tests/invalid/key/no-eol.toml create mode 100644 internal/toml-test/tests/invalid/key/open-bracket.toml create mode 100644 internal/toml-test/tests/invalid/key/partial-quoted.toml create mode 100644 internal/toml-test/tests/invalid/key/single-open-bracket.toml create mode 100644 internal/toml-test/tests/invalid/key/space.toml create mode 100644 internal/toml-test/tests/invalid/key/special-character.toml create mode 100644 internal/toml-test/tests/invalid/key/start-bracket.toml create mode 100644 internal/toml-test/tests/invalid/key/two-equals.toml create mode 100644 internal/toml-test/tests/invalid/key/two-equals2.toml create mode 100644 internal/toml-test/tests/invalid/key/two-equals3.toml create mode 100644 internal/toml-test/tests/invalid/key/without-value-1.toml create mode 100644 internal/toml-test/tests/invalid/key/without-value-2.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-byte-escape.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-codepoint.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-concat.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-escape.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-multiline.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-slash-escape.toml create mode 100644 internal/toml-test/tests/invalid/string/bad-uni-esc.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-byte-escapes.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-1.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-2.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-multiline-quotes.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-multiline-unknown-escape.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-1.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-2.toml create mode 100644 internal/toml-test/tests/invalid/string/basic-unknown-escape.toml create mode 100644 internal/toml-test/tests/invalid/string/literal-multiline-quotes-1.toml create mode 100644 internal/toml-test/tests/invalid/string/literal-multiline-quotes-2.toml create mode 100644 internal/toml-test/tests/invalid/string/missing-quotes.toml create mode 100644 internal/toml-test/tests/invalid/string/multiline-escape-space.toml create mode 100644 internal/toml-test/tests/invalid/string/multiline-no-close-2.toml create mode 100644 internal/toml-test/tests/invalid/string/multiline-no-close.toml create mode 100644 internal/toml-test/tests/invalid/string/multiline-quotes-1.toml create mode 100644 internal/toml-test/tests/invalid/string/multiline-quotes-2.toml create mode 100644 internal/toml-test/tests/invalid/string/no-close.toml create mode 100644 internal/toml-test/tests/invalid/string/text-after-string.toml create mode 100644 internal/toml-test/tests/invalid/string/wrong-close.toml create mode 100644 internal/toml-test/tests/invalid/table/array-empty.toml create mode 100644 internal/toml-test/tests/invalid/table/array-implicit.toml create mode 100644 internal/toml-test/tests/invalid/table/array-missing-bracket.toml create mode 100644 internal/toml-test/tests/invalid/table/duplicate-key-table.toml create mode 100644 internal/toml-test/tests/invalid/table/duplicate-table-array.toml create mode 100644 internal/toml-test/tests/invalid/table/duplicate-table-array2.toml create mode 100644 internal/toml-test/tests/invalid/table/duplicate.toml create mode 100644 internal/toml-test/tests/invalid/table/empty-implicit-table.toml create mode 100644 internal/toml-test/tests/invalid/table/empty.toml create mode 100644 internal/toml-test/tests/invalid/table/equals-sign.toml create mode 100644 internal/toml-test/tests/invalid/table/llbrace.toml create mode 100644 internal/toml-test/tests/invalid/table/nested-brackets-close.toml create mode 100644 internal/toml-test/tests/invalid/table/nested-brackets-open.toml create mode 100644 internal/toml-test/tests/invalid/table/quoted-no-close.toml create mode 100644 internal/toml-test/tests/invalid/table/redefine.toml create mode 100644 internal/toml-test/tests/invalid/table/rrbrace.toml create mode 100644 internal/toml-test/tests/invalid/table/text-after-table.toml create mode 100644 internal/toml-test/tests/invalid/table/whitespace.toml create mode 100644 internal/toml-test/tests/invalid/table/with-pound.toml create mode 100644 internal/toml-test/tests/valid/array/array.json create mode 100644 internal/toml-test/tests/valid/array/array.toml create mode 100644 internal/toml-test/tests/valid/array/bool.json create mode 100644 internal/toml-test/tests/valid/array/bool.toml create mode 100644 internal/toml-test/tests/valid/array/empty.json create mode 100644 internal/toml-test/tests/valid/array/empty.toml create mode 100644 internal/toml-test/tests/valid/array/hetergeneous.json create mode 100644 internal/toml-test/tests/valid/array/hetergeneous.toml create mode 100644 internal/toml-test/tests/valid/array/mixed-int-array.json create mode 100644 internal/toml-test/tests/valid/array/mixed-int-array.toml create mode 100644 internal/toml-test/tests/valid/array/mixed-int-float.json create mode 100644 internal/toml-test/tests/valid/array/mixed-int-float.toml create mode 100644 internal/toml-test/tests/valid/array/mixed-int-string.json create mode 100644 internal/toml-test/tests/valid/array/mixed-int-string.toml create mode 100644 internal/toml-test/tests/valid/array/mixed-string-table.json create mode 100644 internal/toml-test/tests/valid/array/mixed-string-table.toml create mode 100644 internal/toml-test/tests/valid/array/nested-double.json create mode 100644 internal/toml-test/tests/valid/array/nested-double.toml create mode 100644 internal/toml-test/tests/valid/array/nested-inline-table.json create mode 100644 internal/toml-test/tests/valid/array/nested-inline-table.toml create mode 100644 internal/toml-test/tests/valid/array/nested.json create mode 100644 internal/toml-test/tests/valid/array/nested.toml create mode 100644 internal/toml-test/tests/valid/array/nospaces.json create mode 100644 internal/toml-test/tests/valid/array/nospaces.toml create mode 100644 internal/toml-test/tests/valid/array/string-quote-comma-2.json create mode 100644 internal/toml-test/tests/valid/array/string-quote-comma-2.toml create mode 100644 internal/toml-test/tests/valid/array/string-quote-comma.json create mode 100644 internal/toml-test/tests/valid/array/string-quote-comma.toml create mode 100644 internal/toml-test/tests/valid/array/string-with-comma.json create mode 100644 internal/toml-test/tests/valid/array/string-with-comma.toml create mode 100644 internal/toml-test/tests/valid/array/strings.json create mode 100644 internal/toml-test/tests/valid/array/strings.toml create mode 100644 internal/toml-test/tests/valid/array/table-array-string-backslash.json create mode 100644 internal/toml-test/tests/valid/array/table-array-string-backslash.toml create mode 100644 internal/toml-test/tests/valid/bool/bool.json create mode 100644 internal/toml-test/tests/valid/bool/bool.toml create mode 100644 internal/toml-test/tests/valid/comment/at-eof.json create mode 100644 internal/toml-test/tests/valid/comment/at-eof.toml create mode 100644 internal/toml-test/tests/valid/comment/at-eof2.json create mode 100644 internal/toml-test/tests/valid/comment/at-eof2.toml create mode 100644 internal/toml-test/tests/valid/comment/everywhere.json create mode 100644 internal/toml-test/tests/valid/comment/everywhere.toml create mode 100644 internal/toml-test/tests/valid/comment/tricky.json create mode 100644 internal/toml-test/tests/valid/comment/tricky.toml create mode 100644 internal/toml-test/tests/valid/datetime/datetime.json create mode 100644 internal/toml-test/tests/valid/datetime/datetime.toml create mode 100644 internal/toml-test/tests/valid/datetime/local-date.json create mode 100644 internal/toml-test/tests/valid/datetime/local-date.toml create mode 100644 internal/toml-test/tests/valid/datetime/local-time.json create mode 100644 internal/toml-test/tests/valid/datetime/local-time.toml create mode 100644 internal/toml-test/tests/valid/datetime/local.json create mode 100644 internal/toml-test/tests/valid/datetime/local.toml create mode 100644 internal/toml-test/tests/valid/datetime/milliseconds.json create mode 100644 internal/toml-test/tests/valid/datetime/milliseconds.toml create mode 100644 internal/toml-test/tests/valid/datetime/timezone.json create mode 100644 internal/toml-test/tests/valid/datetime/timezone.toml create mode 100644 internal/toml-test/tests/valid/empty-file.json create mode 100644 internal/toml-test/tests/valid/empty-file.toml create mode 100644 internal/toml-test/tests/valid/example.json create mode 100644 internal/toml-test/tests/valid/example.toml create mode 100644 internal/toml-test/tests/valid/float/exponent.json create mode 100644 internal/toml-test/tests/valid/float/exponent.toml create mode 100644 internal/toml-test/tests/valid/float/float.json create mode 100644 internal/toml-test/tests/valid/float/float.toml create mode 100644 internal/toml-test/tests/valid/float/inf-and-nan.json create mode 100644 internal/toml-test/tests/valid/float/inf-and-nan.toml create mode 100644 internal/toml-test/tests/valid/float/long.json create mode 100644 internal/toml-test/tests/valid/float/long.toml create mode 100644 internal/toml-test/tests/valid/float/underscore.json create mode 100644 internal/toml-test/tests/valid/float/underscore.toml create mode 100644 internal/toml-test/tests/valid/float/zero.json create mode 100644 internal/toml-test/tests/valid/float/zero.toml create mode 100644 internal/toml-test/tests/valid/implicit-and-explicit-after.json create mode 100644 internal/toml-test/tests/valid/implicit-and-explicit-after.toml create mode 100644 internal/toml-test/tests/valid/implicit-and-explicit-before.json create mode 100644 internal/toml-test/tests/valid/implicit-and-explicit-before.toml create mode 100644 internal/toml-test/tests/valid/implicit-groups.json create mode 100644 internal/toml-test/tests/valid/implicit-groups.toml create mode 100644 internal/toml-test/tests/valid/inline-table/array.json create mode 100644 internal/toml-test/tests/valid/inline-table/array.toml create mode 100644 internal/toml-test/tests/valid/inline-table/bool.json create mode 100644 internal/toml-test/tests/valid/inline-table/bool.toml create mode 100644 internal/toml-test/tests/valid/inline-table/empty.json create mode 100644 internal/toml-test/tests/valid/inline-table/empty.toml create mode 100644 internal/toml-test/tests/valid/inline-table/end-in-bool.json create mode 100644 internal/toml-test/tests/valid/inline-table/end-in-bool.toml create mode 100644 internal/toml-test/tests/valid/inline-table/inline-table.json create mode 100644 internal/toml-test/tests/valid/inline-table/inline-table.toml create mode 100644 internal/toml-test/tests/valid/inline-table/key-dotted.json create mode 100644 internal/toml-test/tests/valid/inline-table/key-dotted.toml create mode 100644 internal/toml-test/tests/valid/inline-table/multiline.json create mode 100644 internal/toml-test/tests/valid/inline-table/multiline.toml create mode 100644 internal/toml-test/tests/valid/inline-table/nest.json create mode 100644 internal/toml-test/tests/valid/inline-table/nest.toml create mode 100644 internal/toml-test/tests/valid/integer/integer.json create mode 100644 internal/toml-test/tests/valid/integer/integer.toml create mode 100644 internal/toml-test/tests/valid/integer/literals.json create mode 100644 internal/toml-test/tests/valid/integer/literals.toml create mode 100644 internal/toml-test/tests/valid/integer/long.json create mode 100644 internal/toml-test/tests/valid/integer/long.toml create mode 100644 internal/toml-test/tests/valid/integer/underscore.json create mode 100644 internal/toml-test/tests/valid/integer/underscore.toml create mode 100644 internal/toml-test/tests/valid/integer/zero.json create mode 100644 internal/toml-test/tests/valid/integer/zero.toml create mode 100644 internal/toml-test/tests/valid/key/alphanum.json create mode 100644 internal/toml-test/tests/valid/key/alphanum.toml create mode 100644 internal/toml-test/tests/valid/key/case-sensitive.json create mode 100644 internal/toml-test/tests/valid/key/case-sensitive.toml create mode 100644 internal/toml-test/tests/valid/key/dotted.json create mode 100644 internal/toml-test/tests/valid/key/dotted.toml create mode 100644 internal/toml-test/tests/valid/key/empty.json create mode 100644 internal/toml-test/tests/valid/key/empty.toml create mode 100644 internal/toml-test/tests/valid/key/equals-nospace.json create mode 100644 internal/toml-test/tests/valid/key/equals-nospace.toml create mode 100644 internal/toml-test/tests/valid/key/escapes.json create mode 100644 internal/toml-test/tests/valid/key/escapes.toml create mode 100644 internal/toml-test/tests/valid/key/numeric-dotted.json create mode 100644 internal/toml-test/tests/valid/key/numeric-dotted.toml create mode 100644 internal/toml-test/tests/valid/key/numeric.json create mode 100644 internal/toml-test/tests/valid/key/numeric.toml create mode 100644 internal/toml-test/tests/valid/key/quoted-dots.json create mode 100644 internal/toml-test/tests/valid/key/quoted-dots.toml create mode 100644 internal/toml-test/tests/valid/key/space.json create mode 100644 internal/toml-test/tests/valid/key/space.toml create mode 100644 internal/toml-test/tests/valid/key/special-chars.json create mode 100644 internal/toml-test/tests/valid/key/special-chars.toml create mode 100644 internal/toml-test/tests/valid/key/special-word.json create mode 100644 internal/toml-test/tests/valid/key/special-word.toml create mode 100644 internal/toml-test/tests/valid/newline-crlf.json create mode 100644 internal/toml-test/tests/valid/newline-crlf.toml create mode 100644 internal/toml-test/tests/valid/newline-lf.json create mode 100644 internal/toml-test/tests/valid/newline-lf.toml create mode 100644 internal/toml-test/tests/valid/spec-example-1-compact.json create mode 100644 internal/toml-test/tests/valid/spec-example-1-compact.toml create mode 100644 internal/toml-test/tests/valid/spec-example-1.json create mode 100644 internal/toml-test/tests/valid/spec-example-1.toml create mode 100644 internal/toml-test/tests/valid/string/double-quote-escape.json create mode 100644 internal/toml-test/tests/valid/string/double-quote-escape.toml create mode 100644 internal/toml-test/tests/valid/string/empty.json create mode 100644 internal/toml-test/tests/valid/string/empty.toml create mode 100644 internal/toml-test/tests/valid/string/escape-tricky.json create mode 100644 internal/toml-test/tests/valid/string/escape-tricky.toml create mode 100644 internal/toml-test/tests/valid/string/escaped-escape.json create mode 100644 internal/toml-test/tests/valid/string/escaped-escape.toml create mode 100644 internal/toml-test/tests/valid/string/escapes.json create mode 100644 internal/toml-test/tests/valid/string/escapes.toml create mode 100644 internal/toml-test/tests/valid/string/multiline-json create mode 100644 internal/toml-test/tests/valid/string/multiline-quotes.json create mode 100644 internal/toml-test/tests/valid/string/multiline-quotes.toml create mode 100644 internal/toml-test/tests/valid/string/multiline-toml create mode 100644 internal/toml-test/tests/valid/string/nl.json create mode 100644 internal/toml-test/tests/valid/string/nl.toml create mode 100644 internal/toml-test/tests/valid/string/raw-multiline.json create mode 100644 internal/toml-test/tests/valid/string/raw-multiline.toml create mode 100644 internal/toml-test/tests/valid/string/raw.json create mode 100644 internal/toml-test/tests/valid/string/raw.toml create mode 100644 internal/toml-test/tests/valid/string/simple.json create mode 100644 internal/toml-test/tests/valid/string/simple.toml create mode 100644 internal/toml-test/tests/valid/string/unicode-escape.json create mode 100644 internal/toml-test/tests/valid/string/unicode-escape.toml create mode 100644 internal/toml-test/tests/valid/string/unicode-literal.json create mode 100644 internal/toml-test/tests/valid/string/unicode-literal.toml create mode 100644 internal/toml-test/tests/valid/string/with-pound.json create mode 100644 internal/toml-test/tests/valid/string/with-pound.toml create mode 100644 internal/toml-test/tests/valid/table/array-implicit.json create mode 100644 internal/toml-test/tests/valid/table/array-implicit.toml create mode 100644 internal/toml-test/tests/valid/table/array-many.json create mode 100644 internal/toml-test/tests/valid/table/array-many.toml create mode 100644 internal/toml-test/tests/valid/table/array-nest.json create mode 100644 internal/toml-test/tests/valid/table/array-nest.toml create mode 100644 internal/toml-test/tests/valid/table/array-one.json create mode 100644 internal/toml-test/tests/valid/table/array-one.toml create mode 100644 internal/toml-test/tests/valid/table/array-table-array.json create mode 100644 internal/toml-test/tests/valid/table/array-table-array.toml create mode 100644 internal/toml-test/tests/valid/table/empty.json create mode 100644 internal/toml-test/tests/valid/table/empty.toml create mode 100644 internal/toml-test/tests/valid/table/keyword.json create mode 100644 internal/toml-test/tests/valid/table/keyword.toml create mode 100644 internal/toml-test/tests/valid/table/names.json create mode 100644 internal/toml-test/tests/valid/table/names.toml create mode 100644 internal/toml-test/tests/valid/table/no-eol.json create mode 100644 internal/toml-test/tests/valid/table/no-eol.toml create mode 100644 internal/toml-test/tests/valid/table/sub-empty.json create mode 100644 internal/toml-test/tests/valid/table/sub-empty.toml create mode 100644 internal/toml-test/tests/valid/table/whitespace.json create mode 100644 internal/toml-test/tests/valid/table/whitespace.toml create mode 100644 internal/toml-test/tests/valid/table/with-literal-string.json create mode 100644 internal/toml-test/tests/valid/table/with-literal-string.toml create mode 100644 internal/toml-test/tests/valid/table/with-pound.json create mode 100644 internal/toml-test/tests/valid/table/with-pound.toml create mode 100644 internal/toml-test/tests/valid/table/with-single-quotes.json create mode 100644 internal/toml-test/tests/valid/table/with-single-quotes.toml create mode 100644 internal/toml-test/tests/valid/table/without-super.json create mode 100644 internal/toml-test/tests/valid/table/without-super.toml create mode 100644 internal/toml-test/toml.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 028699f3..bda1efba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ } }, "runs-on": "${{ matrix.os }}", + "env": {"GOPROXY": "direct"}, "steps": [ { "name": "Install Go", diff --git a/go.mod b/go.mod index fa7de681..82989481 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/BurntSushi/toml -go 1.13 - -require github.com/BurntSushi/toml-test v1.0.0 +go 1.16 diff --git a/go.sum b/go.sum index 8a6bfc94..e69de29b 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +0,0 @@ -github.com/BurntSushi/toml v0.3.2-0.20210614224209-34d990aa228d/go.mod h1:2QZjSXA5e+XyFeCAxxtL8Z4StYUsTquL8ODGPR3C3MA= -github.com/BurntSushi/toml v0.3.2-0.20210621044154-20a94d639b8e/go.mod h1:t4zg8TkHfP16Vb3x4WKIw7zVYMit5QFtPEO8lOWxzTg= -github.com/BurntSushi/toml v0.3.2-0.20210624061728-01bfc69d1057/go.mod h1:NMj2lD5LfMqcE0w8tnqOsH6944oaqpI1974lrIwerfE= -github.com/BurntSushi/toml v0.3.2-0.20210704081116-ccff24ee4463/go.mod h1:EkRrMiQQmfxK6kIldz3QbPlhmVkrjW1RDJUnbDqGYvc= -github.com/BurntSushi/toml v0.4.0/go.mod h1:wtejDu7Q0FhCWAo2aXkywSJyYFg01EDTKozLNCz2JBA= -github.com/BurntSushi/toml-test v0.1.1-0.20210620192437-de01089bbf76/go.mod h1:P/PrhmZ37t5llHfDuiouWXtFgqOoQ12SAh9j6EjrBR4= -github.com/BurntSushi/toml-test v0.1.1-0.20210624055653-1f6389604dc6/go.mod h1:UAIt+Eo8itMZAAgImXkPGDMYsT1SsJkVdB5TuONl86A= -github.com/BurntSushi/toml-test v0.1.1-0.20210704062846-269931e74e3f/go.mod h1:fnFWrIwqgHsEjVsW3RYCJmDo86oq9eiJ9u6bnqhtm2g= -github.com/BurntSushi/toml-test v0.1.1-0.20210723065233-facb9eccd4da/go.mod h1:ve9Q/RRu2vHi42LocPLNvagxuUJh993/95b18bw/Nws= -github.com/BurntSushi/toml-test v1.0.0 h1:auSA806b0nBApu9BNK0waBUzaydmHd9TpLIM1UFkvKg= -github.com/BurntSushi/toml-test v1.0.0/go.mod h1:XDBCig4BwVX4bO0Ei0EU51EJ6DamtW+xOoH7+Vkhlz0= -zgo.at/zli v0.0.0-20210619044753-e7020a328e59/go.mod h1:HLAc12TjNGT+VRXr76JnsNE3pbooQtwKWhX+RlDjQ2Y= diff --git a/internal/toml-test/.gitignore b/internal/toml-test/.gitignore new file mode 100644 index 00000000..d8b7327b --- /dev/null +++ b/internal/toml-test/.gitignore @@ -0,0 +1,2 @@ +/dist +/toml-test diff --git a/internal/toml-test/.gogo-release b/internal/toml-test/.gogo-release new file mode 100644 index 00000000..d454f1b9 --- /dev/null +++ b/internal/toml-test/.gogo-release @@ -0,0 +1 @@ +build_flags="$build_flags ./cmd/toml-test" diff --git a/internal/toml-test/COPYING b/internal/toml-test/COPYING new file mode 100644 index 00000000..93b22020 --- /dev/null +++ b/internal/toml-test/COPYING @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 TOML authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/internal/toml-test/README.md b/internal/toml-test/README.md new file mode 100644 index 00000000..5da06f78 --- /dev/null +++ b/internal/toml-test/README.md @@ -0,0 +1,258 @@ +`toml-test` is a language-agnostic test suite to verify the correctness of +[TOML][t] parsers and writers. + +Tests are divided into two groups: "invalid" and "valid". Decoders or encoders +that reject "invalid" tests pass the tests, and decoders that accept "valid" +tests and output precisely what is expected pass the tests. The output format is +JSON, described below. + +Both encoders and decoders share valid tests, except an encoder accepts JSON and +outputs TOML rather than the reverse. The TOML representations are read with a +blessed decoder and is compared. Encoders have their own set of invalid tests in +the invalid-encoder directory. The JSON given to a TOML encoder is in the same +format as the JSON that a TOML decoder should output. + +Compatible with TOML version [v1.0.0][v1]. + +[t]: https://toml.io +[v1]: https://toml.io/en/v1.0.0 + +Installation +------------ +There are binaries on the [release page][r]; these are statically compiled and +should run in most environments. It's recommended you use a binary, or a tagged +release if you build from source especially in CI environments. This prevents +your tests from breaking on changes to tests in this tool. + +To compile from source you will need Go 1.16 or newer (older versions will *not* +work): + + $ git clone https://github.com/BurntSushi/toml-test.git + $ cd toml-test + $ go build ./cmd/toml-test + +This will build a `./toml-test` binary. + +[r]: https://github.com/BurntSushi/toml-test/releases + +Usage +----- +`toml-test` accepts an encoder or decoder as the first positional argument, for +example: + + $ toml-test my-toml-decoder + $ toml-test my-toml-encoder -encoder + +The `-encoder` flag is used to signal that this is an encoder rather than a +decoder. + +For example, to run the tests against the Go TOML library: + + # Install my parser + $ go install github.com/BurntSushi/toml/cmd/toml-test-decoder@master + $ go install github.com/BurntSushi/toml/cmd/toml-test-encoder@master + + $ toml-test toml-test-decoder + toml-test [toml-test-decoder]: using embeded tests: 278 passed + + $ toml-test -encoder toml-test-encoder + toml-test [toml-test-encoder]: using embeded tests: 94 passed, 0 failed + +The default is to use the tests compiled in the binary; you can use `-testdir` +to load tests from the filesystem. You can use `-run [name]` or `-skip [name]` +to run or skip specific tests. Both flags can be given more than once and accept +glob patterns: `-run 'valid/string/*'`. + +See `toml-test -help` for detailed usage. + +### Implementing a decoder +For your decoder to be compatible with `toml-test` it **must** satisfy the +expected interface: + +- Your decoder **must** accept TOML data on `stdin` until EOF. +- If the TOML data is invalid, your decoder **must** return with a non-zero + exit, code indicating an error. +- If the TOML data is valid, your decoder **must** output a JSON encoding of + that data on `stdout` and return with a zero exit code indicating success. + +An example in pseudocode: + + toml_data = read_stdin() + + parsed_toml = decode_toml(toml_data) + + if error_parsing_toml(): + print_error_to_stderr() + exit(1) + + print_as_tagged_json(parsed_toml) + exit(0) + +Details on the tagged JSON is explained below in "JSON encoding". + +### Implementing an encoder +For your encoder to be compatible with `toml-test`, it **must** satisfy the +expected interface: + +- Your encoder **must** accept JSON data on `stdin` until EOF. +- If the JSON data cannot be converted to a valid TOML representation, your + encoder **must** return with a non-zero exit code indicating an error. +- If the JSON data can be converted to a valid TOML representation, your encoder + **must** output a TOML encoding of that data on `stdout` and return with a + zero exit code indicating success. + +An example in pseudocode: + + json_data = read_stdin() + + parsed_json_with_tags = decode_json(json_data) + + if error_parsing_json(): + print_error_to_stderr() + exit(1) + + print_as_toml(parsed_json_with_tags) + exit(0) + +JSON encoding +------------- +The following JSON encoding applies equally to both encoders and decoders: + +- TOML tables correspond to JSON objects. +- TOML table arrays correspond to JSON arrays. +- TOML values correspond to a special JSON object of the form: + `{"type": "{TTYPE}", "value": {TVALUE}}` + +In the above, `TTYPE` may be one of: + +- string +- integer +- float +- bool +- datetime +- datetime-local +- date-local +- time-local + +`TVALUE` is always a JSON string. + +Empty hashes correspond to empty JSON objects (`{}`) and empty arrays correspond +to empty JSON arrays (`[]`). + +Offset datetimes should be encoded in RFC 3339; Local datetimes should be +encoded following RFC 3339 without the offset part. Local dates should be +encoded as the date part of RFC 3339 and Local times as the time part. + +Examples: + + TOML JSON + + a = 42 {"type": "integer": "value": "42} + +--- + + [tbl] {"tbl": { + a = 42 "a": {"type": "integer": "value": "42} + }} + +--- + + a = ["a", 2] {"a": [ + {"type": "string", "value": "1"}, + {"type: "integer": "value": "2"} + ]} + +Or a more complex example: + +```toml +best-day-ever = 1987-07-05T17:45:00Z + +[numtheory] +boring = false +perfection = [6, 28, 496] +``` + +And the JSON encoding expected by `toml-test` is: + +```json +{ + "best-day-ever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, + "numtheory": { + "boring": {"type": "bool", "value": "false"}, + "perfection": [ + {"type": "integer", "value": "6"}, + {"type": "integer", "value": "28"}, + {"type": "integer", "value": "496"} + ] + } +} +``` + +Note that the only JSON values ever used are objects, arrays and strings. + +An example implementation can be found in the BurnSushi/toml: + +- [Add tags](https://github.com/BurntSushi/toml/blob/master/internal/tag/add.go) +- [Remove tags](https://github.com/BurntSushi/toml/blob/master/internal/tag/rm.go) + +Assumptions of Truth +-------------------- +The following are taken as ground truths by `toml-test`: + +- All tests classified as `invalid` **are** invalid. +- All tests classified as `valid` **are** valid. +- All expected outputs in `valid/test-name.json` are exactly correct. +- The Go standard library package `encoding/json` decodes JSON correctly. +- When testing encoders, the TOML decoder at + [BurntSushi/toml](https://github.com/BurntSushi/toml) is assumed to be + correct. (Note that this assumption is not made when testing decoders!) + +Of particular note is that **no TOML decoder** is taken as ground truth when +testing decoders. This means that most changes to the spec will only require an +update of the tests in `toml-test`. (Bigger changes may require an adjustment of +how two things are considered equal. Particularly if a new type of data is +added.) Obviously, this advantage does not apply to testing TOML encoders since +there must exist a TOML decoder that conforms to the specification in order to +read the output of a TOML encoder. + +Adding tests +------------ +`toml-test` was designed so that tests can be easily added and removed. As +mentioned above, tests are split into two groups: invalid and valid tests. + +Invalid tests **only check if a decoder rejects invalid TOML data**. Or, in the +case of testing encoders, invalid tests **only check if an encoder rejects an +invalid representation of TOML** (e.g., a hetergeneous array). Therefore, all +invalid tests should try to **test one thing and one thing only**. Invalid tests +should be named after the fault it is trying to expose. Invalid tests for +decoders are in the `tests/invalid` directory while invalid tests for encoders +are in the `tests/invalid-encoder` directory. + +Valid tests check that a decoder accepts valid TOML data **and** that the parser +has the correct representation of the TOML data. Therefore, valid tests need a +JSON encoding in addition to the TOML data. The tests should be small enough +that writing the JSON encoding by hand will not give you brain damage. The exact +reverse is true when testing encoders. + +A valid test without either a `.json` or `.toml` file will automatically fail. + +If you have tests that you'd like to add, please submit a pull request. + +Why JSON? +--------- +In order for a language agnostic test suite to work, we need some kind of data +exchange format. TOML cannot be used, as it would imply that a particular parser +has a blessing of correctness. + +My decision to use JSON was not a careful one. It was based on expediency. The +Go standard library has an excellent `encoding/json` package built in, which +made it easy to compare JSON data. + +The problem with JSON is that the types in TOML are not in one-to-one +correspondence with JSON. This is why every TOML value represented in JSON is +tagged with a type annotation, as described above. + +YAML may be closer in correspondence with TOML, but I don't believe we should +rely on that correspondence. Making things explicit with JSON means that writing +tests is a little more cumbersome, but it also reduces the number of assumptions +we need to make. diff --git a/internal/toml-test/gen-multi.py b/internal/toml-test/gen-multi.py new file mode 100644 index 00000000..4728ab79 --- /dev/null +++ b/internal/toml-test/gen-multi.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import glob +import os.path + +for f in glob.glob('tests/invalid/*/*.multi'): + base = os.path.dirname(f[:-6]) + for l in open(f, 'rb').readlines(): + name = l.split(b'=')[0].strip().decode() + if name == '' or name[0] == '#': + continue + path = base + "/" + name + '.toml' + with open(path, 'wb+') as fp: + fp.write(l) diff --git a/internal/toml-test/json.go b/internal/toml-test/json.go new file mode 100644 index 00000000..bb46425c --- /dev/null +++ b/internal/toml-test/json.go @@ -0,0 +1,265 @@ +// +build go1.16 + +package tomltest + +import ( + "strconv" + "strings" + "time" +) + +// cmpJSON consumes the recursive structure of both want and have +// simultaneously. If anything is unequal, the result has failed and comparison +// stops. +// +// reflect.DeepEqual could work here, but it won't tell us how the two +// structures are different. +func (r Test) cmpJSON(want, have interface{}) Test { + switch w := want.(type) { + case map[string]interface{}: + return r.cmpJSONMaps(w, have) + case []interface{}: + return r.cmpJSONArrays(w, have) + default: + return r.fail( + "Key '%s' in expected output should be a map or a list of maps, but it's a %T", + r.Key, want) + } +} + +func (r Test) cmpJSONMaps(want map[string]interface{}, have interface{}) Test { + haveMap, ok := have.(map[string]interface{}) + if !ok { + return r.mismatch("table", want, haveMap) + } + + // Check to make sure both or neither are values. + if isValue(want) && !isValue(haveMap) { + return r.fail( + "Key '%s' is supposed to be a value, but the parser reports it as a table", + r.Key) + } + if !isValue(want) && isValue(haveMap) { + return r.fail( + "Key '%s' is supposed to be a table, but the parser reports it as a value", + r.Key) + } + if isValue(want) && isValue(haveMap) { + return r.cmpJSONValues(want, haveMap) + } + + // Check that the keys of each map are equivalent. + for k := range want { + if _, ok := haveMap[k]; !ok { + bunk := r.kjoin(k) + return bunk.fail("Could not find key '%s' in parser output.", + bunk.Key) + } + } + for k := range haveMap { + if _, ok := want[k]; !ok { + bunk := r.kjoin(k) + return bunk.fail("Could not find key '%s' in expected output.", + bunk.Key) + } + } + + // Okay, now make sure that each value is equivalent. + for k := range want { + if sub := r.kjoin(k).cmpJSON(want[k], haveMap[k]); sub.Failed() { + return sub + } + } + return r +} + +func (r Test) cmpJSONArrays(want, have interface{}) Test { + wantSlice, ok := want.([]interface{}) + if !ok { + return r.bug("'value' should be a JSON array when 'type=array', but it is a %T", want) + } + + haveSlice, ok := have.([]interface{}) + if !ok { + return r.fail( + "Malformed output from your encoder: 'value' is not a JSON array: %T", have) + } + + if len(wantSlice) != len(haveSlice) { + return r.fail("Array lengths differ for key '%s':\n"+ + " Expected: %d\n"+ + " Your encoder: %d", + r.Key, len(wantSlice), len(haveSlice)) + } + for i := 0; i < len(wantSlice); i++ { + if sub := r.cmpJSON(wantSlice[i], haveSlice[i]); sub.Failed() { + return sub + } + } + return r +} + +func (r Test) cmpJSONValues(want, have map[string]interface{}) Test { + wantType, ok := want["type"].(string) + if !ok { + return r.bug("'type' should be a string, but it is a %T", want["type"]) + } + + haveType, ok := have["type"].(string) + if !ok { + return r.fail("Malformed output from your encoder: 'type' is not a string: %T", have["type"]) + } + + if wantType != haveType { + return r.valMismatch(wantType, haveType, want, have) + } + + // If this is an array, then we've got to do some work to check equality. + if wantType == "array" { + return r.cmpJSONArrays(want, have) + } + + // Atomic values are always strings + wantVal, ok := want["value"].(string) + if !ok { + return r.bug("'value' %v should be a string, but it is a %[1]T", want["value"]) + } + + haveVal, ok := have["value"].(string) + if !ok { + return r.fail("Malformed output from your encoder: %T is not a string", have["value"]) + } + + // Excepting floats and datetimes, other values can be compared as strings. + switch wantType { + case "float": + return r.cmpFloats(wantVal, haveVal) + case "datetime", "datetime-local", "date-local", "time-local": + return r.cmpAsDatetimes(wantType, wantVal, haveVal) + default: + return r.cmpAsStrings(wantVal, haveVal) + } +} + +func (r Test) cmpAsStrings(want, have string) Test { + if want != have { + return r.fail("Values for key '%s' don't match:\n"+ + " Expected: %s\n"+ + " Your encoder: %s", + r.Key, want, have) + } + return r +} + +func (r Test) cmpFloats(want, have string) Test { + // Special case for NaN, since NaN != NaN. + if strings.HasSuffix(want, "nan") || strings.HasSuffix(have, "nan") { + if want != have { + return r.fail("Values for key '%s' don't match:\n"+ + " Expected: %v\n"+ + " Your encoder: %v", + r.Key, want, have) + } + return r + } + + wantF, err := strconv.ParseFloat(want, 64) + if err != nil { + return r.bug("Could not read '%s' as a float value for key '%s'", want, r.Key) + } + + haveF, err := strconv.ParseFloat(have, 64) + if err != nil { + return r.fail("Malformed output from your encoder: key '%s' is not a float: '%s'", r.Key, have) + } + + if wantF != haveF { + return r.fail("Values for key '%s' don't match:\n"+ + " Expected: %v\n"+ + " Your encoder: %v", + r.Key, wantF, haveF) + } + return r +} + +var datetimeRepl = strings.NewReplacer( + " ", "T", + "t", "T", + "z", "Z") + +var layouts = map[string]string{ + "datetime": time.RFC3339Nano, + "datetime-local": "2006-01-02T15:04:05.999999999", + "date-local": "2006-01-02", + "time-local": "15:04:05", +} + +func (r Test) cmpAsDatetimes(kind, want, have string) Test { + layout, ok := layouts[kind] + if !ok { + panic("should never happen") + } + + wantT, err := time.Parse(layout, datetimeRepl.Replace(want)) + if err != nil { + return r.bug("Could not read '%s' as a datetime value for key '%s'", want, r.Key) + } + + haveT, err := time.Parse(layout, datetimeRepl.Replace(want)) + if err != nil { + return r.fail("Malformed output from your encoder: key '%s' is not a datetime: '%s'", r.Key, have) + } + if !wantT.Equal(haveT) { + return r.fail("Values for key '%s' don't match:\n"+ + " Expected: %v\n"+ + " Your encoder: %v", + r.Key, wantT, haveT) + } + return r +} + +func (r Test) cmpAsDatetimesLocal(want, have string) Test { + if datetimeRepl.Replace(want) != datetimeRepl.Replace(have) { + return r.fail("Values for key '%s' don't match:\n"+ + " Expected: %v\n"+ + " Your encoder: %v", + r.Key, want, have) + } + return r +} + +func (r Test) kjoin(key string) Test { + if len(r.Key) == 0 { + r.Key = key + } else { + r.Key += "." + key + } + return r +} + +func isValue(m map[string]interface{}) bool { + if len(m) != 2 { + return false + } + if _, ok := m["type"]; !ok { + return false + } + if _, ok := m["value"]; !ok { + return false + } + return true +} + +func (r Test) mismatch(wantType string, want, have interface{}) Test { + return r.fail("Key '%s' is not an %s but %[4]T:\n"+ + " Expected: %#[3]v\n"+ + " Your encoder: %#[4]v", + r.Key, wantType, want, have) +} + +func (r Test) valMismatch(wantType, haveType string, want, have interface{}) Test { + return r.fail("Key '%s' is not an %s but %s:\n"+ + " Expected: %#[3]v\n"+ + " Your encoder: %#[4]v", + r.Key, wantType, want, have) +} diff --git a/internal/toml-test/runner.go b/internal/toml-test/runner.go new file mode 100644 index 00000000..d3044a5c --- /dev/null +++ b/internal/toml-test/runner.go @@ -0,0 +1,393 @@ +// +build go1.16 + +//go:generate ./gen-multi.py + +package tomltest + +import ( + "bytes" + "embed" + "encoding/json" + "errors" + "fmt" + "io/fs" + "os" + "os/exec" + "path/filepath" + "strings" + + "github.com/BurntSushi/toml" +) + +type testType uint8 + +const ( + TypeValid testType = iota + TypeInvalid +) + +//go:embed tests/* +var embeddedTests embed.FS + +// EmbeddedTests are the tests embedded in toml-test, rooted to the "test/" +// directory. +func EmbeddedTests() fs.FS { + f, err := fs.Sub(embeddedTests, "tests") + if err != nil { + panic(err) + } + return f +} + +// Runner runs a set of tests. +// +// The validity of the parameters is not checked extensively; the caller should +// verify this if need be. See ./cmd/toml-test for an example. +type Runner struct { + Files fs.FS // Test files. + Encoder bool // Are we testing an encoder? + RunTests []string // Tests to run; run all if blank. + SkipTests []string // Tests to skip. + Parser Parser // Send data to a parser. +} + +// A Parser instance is used to call the TOML parser we test. +// +// By default this is done through an external command. +type Parser interface { + // Encode a JSON string to TOML. + // + // The output is the TOML string; if outputIsError is true then it's assumed + // that an encoding error occurred. + // + // An error return should only be used in case an unrecoverable error + // occurred; failing to encode to TOML is not an error, but the encoder + // unexpectedly panicking is. + Encode(jsonInput string) (output string, outputIsError bool, err error) + + // Decode a TOML string to JSON. The same semantics as Encode apply. + Decode(tomlInput string) (output string, outputIsError bool, err error) +} + +// CommandParser calls an external command. +type CommandParser struct { + fsys fs.FS + cmd []string +} + +// Tests are tests to run. +type Tests struct { + Tests []Test + + // Set when test are run. + + Skipped, Passed, Failed int +} + +// Result is the result of a single test. +type Test struct { + Path string // Path of test, e.g. "valid/string-test" + + // Set when a test is run. + + Skipped bool // Skipped this test? + Failure string // Failure message. + Key string // TOML key the failure occured on; may be blank. + Encoder bool // Encoder test? + Input string // The test case that we sent to the external program. + Output string // Output from the external program. + Want string // The output we want. + OutputFromStderr bool // The Output came from stderr, not stdout. +} + +// List all tests in Files. +func (r Runner) List() ([]string, error) { + ls := make([]string, 0, 256) + if err := r.findTOML("valid", &ls); err != nil { + return nil, fmt.Errorf("reading 'valid/' dir: %w", err) + } + + d := "invalid" + map[bool]string{true: "-encoder", false: ""}[r.Encoder] + if err := r.findTOML(d, &ls); err != nil { + return nil, fmt.Errorf("reading %q dir: %w", d, err) + } + return ls, nil +} + +// Run all tests listed in t.RunTests. +// +// TODO: give option to: +// - Run all tests with \n replaced with \r\n +// - Run all tests with '# comment' appended to every line. +func (r Runner) Run() (Tests, error) { + skipped, err := r.findTests() + if err != nil { + return Tests{}, fmt.Errorf("tomltest.Runner.Run: %w", err) + } + + tests := Tests{Tests: make([]Test, 0, len(r.RunTests)), Skipped: skipped} + for _, p := range r.RunTests { + if r.hasSkip(p) { + tests.Skipped++ + tests.Tests = append(tests.Tests, Test{Path: p, Skipped: true, Encoder: r.Encoder}) + continue + } + + t := Test{Path: p, Encoder: r.Encoder}.Run(r.Parser, r.Files) + tests.Tests = append(tests.Tests, t) + + if t.Failed() { + tests.Failed++ + } else { + tests.Passed++ + } + } + + return tests, nil +} + +// find all TOML files in 'path' relative to the test directory. +func (r Runner) findTOML(path string, appendTo *[]string) error { + err := fs.WalkDir(r.Files, path, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() || !strings.HasSuffix(path, ".toml") { + return nil + } + + *appendTo = append(*appendTo, strings.TrimSuffix(path, ".toml")) + return nil + }) + + // It's okay if the directory doesn't exist. + var pErr *os.PathError + if errors.As(err, &pErr) && pErr.Op == "open" && pErr.Path == path { + return nil + } + return err +} + +// Expand RunTest glob patterns, or return all tests if RunTests if empty. +func (r *Runner) findTests() (int, error) { + ls, err := r.List() + if err != nil { + return 0, err + } + + var skip int + + if len(r.RunTests) == 0 { + r.RunTests = ls + } else { + run := make([]string, 0, len(r.RunTests)) + for _, l := range ls { + for _, r := range r.RunTests { + if m, _ := filepath.Match(r, l); m { + run = append(run, l) + break + } + } + } + r.RunTests, skip = run, len(ls)-len(run) + } + + // Expand invalid tests ending in ".multi.toml" + expanded := make([]string, 0, len(r.RunTests)) + for _, path := range r.RunTests { + if !strings.HasSuffix(path, ".multi") { + expanded = append(expanded, path) + continue + } + + d, err := fs.ReadFile(r.Files, path+".toml") + if err != nil { + return 0, err + } + + fmt.Println(string(d)) + } + r.RunTests = expanded + + return skip, nil +} + +func (r Runner) hasSkip(path string) bool { + for _, s := range r.SkipTests { + if m, _ := filepath.Match(s, path); m { + return true + } + } + return false +} + +func (c CommandParser) Encode(input string) (output string, outputIsError bool, err error) { + stdout, stderr := new(bytes.Buffer), new(bytes.Buffer) + cmd := exec.Command(c.cmd[0]) + cmd.Args = c.cmd + cmd.Stdin, cmd.Stdout, cmd.Stderr = strings.NewReader(input), stdout, stderr + + err = cmd.Run() + if err != nil { + eErr := &exec.ExitError{} + if errors.As(err, &eErr) { + fmt.Fprintf(stderr, "\nExit %d\n", eErr.ProcessState.ExitCode()) + err = nil + } + } + + if stderr.Len() > 0 { + return strings.TrimSpace(stderr.String()) + "\n", true, err + } + return strings.TrimSpace(stdout.String()) + "\n", false, err +} +func NewCommandParser(fsys fs.FS, cmd []string) CommandParser { return CommandParser{fsys, cmd} } +func (c CommandParser) Decode(input string) (string, bool, error) { return c.Encode(input) } + +// Run this test. +func (t Test) Run(p Parser, fsys fs.FS) Test { + if t.Type() == TypeInvalid { + return t.runInvalid(p, fsys) + } + return t.runValid(p, fsys) +} + +func (t Test) runInvalid(p Parser, fsys fs.FS) Test { + var err error + _, t.Input, err = t.ReadInput(fsys) + if err != nil { + return t.bug(err.Error()) + } + + if t.Encoder { + t.Output, t.OutputFromStderr, err = p.Encode(t.Input) + } else { + t.Output, t.OutputFromStderr, err = p.Decode(t.Input) + } + if err != nil { + return t.fail(err.Error()) + } + if !t.OutputFromStderr { + return t.fail("Expected an error, but no error was reported.") + } + return t +} + +func (t Test) runValid(p Parser, fsys fs.FS) Test { + var err error + _, t.Input, err = t.ReadInput(fsys) + if err != nil { + return t.bug(err.Error()) + } + + if t.Encoder { + t.Output, t.OutputFromStderr, err = p.Encode(t.Input) + } else { + t.Output, t.OutputFromStderr, err = p.Decode(t.Input) + } + if err != nil { + return t.fail(err.Error()) + } + if t.OutputFromStderr { + return t.fail(t.Output) + } + if t.Output == "" { + // Special case: we expect an empty output here. + if t.Path != "valid/empty-file" { + return t.fail("stdout is empty") + } + } + + // Compare for encoder test + if t.Encoder { + want, err := t.ReadWantTOML(fsys) + if err != nil { + return t.bug(err.Error()) + } + var have interface{} + if _, err := toml.Decode(t.Output, &have); err != nil { + //return t.fail("decode TOML from encoder %q:\n %s", cmd, err) + return t.fail("decode TOML from encoder:\n %s", err) + } + return t.cmpTOML(want, have) + } + + // Compare for decoder test + want, err := t.ReadWantJSON(fsys) + if err != nil { + return t.fail(err.Error()) + } + + var have interface{} + if err := json.Unmarshal([]byte(t.Output), &have); err != nil { + return t.fail("decode JSON output from parser:\n %s", err) + } + + return t.cmpJSON(want, have) +} + +// ReadInput reads the file sent to the encoder. +func (t Test) ReadInput(fsys fs.FS) (path, data string, err error) { + path = t.Path + map[bool]string{true: ".json", false: ".toml"}[t.Encoder] + d, err := fs.ReadFile(fsys, path) + if err != nil { + return path, "", err + } + return path, string(d), nil +} + +func (t Test) ReadWant(fsys fs.FS) (path, data string, err error) { + if t.Type() == TypeInvalid { + panic("testoml.Test.ReadWant: invalid tests do not have a 'correct' version") + } + + path = t.Path + map[bool]string{true: ".toml", false: ".json"}[t.Encoder] + d, err := fs.ReadFile(fsys, path) + if err != nil { + return path, "", err + } + return path, string(d), nil +} + +func (t *Test) ReadWantJSON(fsys fs.FS) (v interface{}, err error) { + var path string + path, t.Want, err = t.ReadWant(fsys) + if err != nil { + return nil, err + } + + if err := json.Unmarshal([]byte(t.Want), &v); err != nil { + return nil, fmt.Errorf("decode JSON file %q:\n %s", path, err) + } + return v, nil +} +func (t *Test) ReadWantTOML(fsys fs.FS) (v interface{}, err error) { + var path string + path, t.Want, err = t.ReadWant(fsys) + if err != nil { + return nil, err + } + _, err = toml.Decode(t.Want, &v) + if err != nil { + return nil, fmt.Errorf("Could not decode TOML file %q:\n %s", path, err) + } + return v, nil +} + +// Test type: "valid", "invalid" +func (t Test) Type() testType { + if strings.HasPrefix(t.Path, "invalid") { + return TypeInvalid + } + return TypeValid +} + +func (t Test) fail(format string, v ...interface{}) Test { + t.Failure = fmt.Sprintf(format, v...) + return t +} +func (t Test) bug(format string, v ...interface{}) Test { + return t.fail("BUG IN TEST CASE: "+format, v...) +} + +func (t Test) Failed() bool { return t.Failure != "" } diff --git a/internal/toml-test/tests/.gitattributes b/internal/toml-test/tests/.gitattributes new file mode 100644 index 00000000..63816554 --- /dev/null +++ b/internal/toml-test/tests/.gitattributes @@ -0,0 +1 @@ +*.toml -text diff --git a/internal/toml-test/tests/invalid/array/missing-separator.toml b/internal/toml-test/tests/invalid/array/missing-separator.toml new file mode 100644 index 00000000..ab3791af --- /dev/null +++ b/internal/toml-test/tests/invalid/array/missing-separator.toml @@ -0,0 +1 @@ +wrong = [ 1 2 3 ] diff --git a/internal/toml-test/tests/invalid/array/no-close-2.toml b/internal/toml-test/tests/invalid/array/no-close-2.toml new file mode 100644 index 00000000..2f46123f --- /dev/null +++ b/internal/toml-test/tests/invalid/array/no-close-2.toml @@ -0,0 +1 @@ +x = [42 # diff --git a/internal/toml-test/tests/invalid/array/no-close-table-2.toml b/internal/toml-test/tests/invalid/array/no-close-table-2.toml new file mode 100644 index 00000000..827c1284 --- /dev/null +++ b/internal/toml-test/tests/invalid/array/no-close-table-2.toml @@ -0,0 +1 @@ +x = [{ key = 42 # diff --git a/internal/toml-test/tests/invalid/array/no-close-table.toml b/internal/toml-test/tests/invalid/array/no-close-table.toml new file mode 100644 index 00000000..7b077beb --- /dev/null +++ b/internal/toml-test/tests/invalid/array/no-close-table.toml @@ -0,0 +1 @@ +x = [{ key = 42 diff --git a/internal/toml-test/tests/invalid/array/no-close.toml b/internal/toml-test/tests/invalid/array/no-close.toml new file mode 100644 index 00000000..032ebcc2 --- /dev/null +++ b/internal/toml-test/tests/invalid/array/no-close.toml @@ -0,0 +1 @@ +long_array = [ 1, 2, 3 diff --git a/internal/toml-test/tests/invalid/array/tables-1.toml b/internal/toml-test/tests/invalid/array/tables-1.toml new file mode 100644 index 00000000..01d4d138 --- /dev/null +++ b/internal/toml-test/tests/invalid/array/tables-1.toml @@ -0,0 +1,4 @@ +# INVALID TOML DOC +fruit = [] + +[[fruit]] # Not allowed diff --git a/internal/toml-test/tests/invalid/array/tables-2.toml b/internal/toml-test/tests/invalid/array/tables-2.toml new file mode 100644 index 00000000..a77b0e4d --- /dev/null +++ b/internal/toml-test/tests/invalid/array/tables-2.toml @@ -0,0 +1,10 @@ +# INVALID TOML DOC +[[fruit]] + name = "apple" + + [[fruit.variety]] + name = "red delicious" + + # This table conflicts with the previous table + [fruit.variety] + name = "granny smith" diff --git a/internal/toml-test/tests/invalid/array/text-after-array-entries.toml b/internal/toml-test/tests/invalid/array/text-after-array-entries.toml new file mode 100644 index 00000000..1a728907 --- /dev/null +++ b/internal/toml-test/tests/invalid/array/text-after-array-entries.toml @@ -0,0 +1,4 @@ +array = [ + "Is there life after an array separator?", No + "Entry" +] diff --git a/internal/toml-test/tests/invalid/array/text-before-array-separator.toml b/internal/toml-test/tests/invalid/array/text-before-array-separator.toml new file mode 100644 index 00000000..9b06a392 --- /dev/null +++ b/internal/toml-test/tests/invalid/array/text-before-array-separator.toml @@ -0,0 +1,4 @@ +array = [ + "Is there life before an array separator?" No, + "Entry" +] diff --git a/internal/toml-test/tests/invalid/array/text-in-array.toml b/internal/toml-test/tests/invalid/array/text-in-array.toml new file mode 100644 index 00000000..a6a6c420 --- /dev/null +++ b/internal/toml-test/tests/invalid/array/text-in-array.toml @@ -0,0 +1,5 @@ +array = [ + "Entry 1", + I don't belong, + "Entry 2", +] diff --git a/internal/toml-test/tests/invalid/bool/mixed-case.toml b/internal/toml-test/tests/invalid/bool/mixed-case.toml new file mode 100644 index 00000000..41d995a2 --- /dev/null +++ b/internal/toml-test/tests/invalid/bool/mixed-case.toml @@ -0,0 +1 @@ +valid = False diff --git a/internal/toml-test/tests/invalid/bool/wrong-case-false.toml b/internal/toml-test/tests/invalid/bool/wrong-case-false.toml new file mode 100644 index 00000000..39822209 --- /dev/null +++ b/internal/toml-test/tests/invalid/bool/wrong-case-false.toml @@ -0,0 +1 @@ +b = FALSE diff --git a/internal/toml-test/tests/invalid/bool/wrong-case-true.toml b/internal/toml-test/tests/invalid/bool/wrong-case-true.toml new file mode 100644 index 00000000..85e34c5e --- /dev/null +++ b/internal/toml-test/tests/invalid/bool/wrong-case-true.toml @@ -0,0 +1 @@ +a = TRUE diff --git a/internal/toml-test/tests/invalid/control/comment-del.toml b/internal/toml-test/tests/invalid/control/comment-del.toml new file mode 100644 index 00000000..fb904007 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/comment-del.toml @@ -0,0 +1 @@ +comment-del = "0x7f" #  diff --git a/internal/toml-test/tests/invalid/control/comment-lf.toml b/internal/toml-test/tests/invalid/control/comment-lf.toml new file mode 100644 index 00000000..f6e963e0 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/comment-lf.toml @@ -0,0 +1 @@ +comment-lf = "ctrl-P" #  diff --git a/internal/toml-test/tests/invalid/control/comment-null.toml b/internal/toml-test/tests/invalid/control/comment-null.toml new file mode 100644 index 0000000000000000000000000000000000000000..2c903729b9a0731eebedef6c551fe9ddb30ba882 GIT binary patch literal 26 ecmYe!&&^HEE78p>&B;-)RZs%aN(#yf3|s(wpa;bO literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/control/comment-us.toml b/internal/toml-test/tests/invalid/control/comment-us.toml new file mode 100644 index 00000000..c685b798 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/comment-us.toml @@ -0,0 +1 @@ +comment-us = "ctrl-_" #  diff --git a/internal/toml-test/tests/invalid/control/control.multi b/internal/toml-test/tests/invalid/control/control.multi new file mode 100644 index 0000000000000000000000000000000000000000..08c0e25b373fc9d9abcb25b554cc5ff3bd15f6f7 GIT binary patch literal 568 zcmY+Bv2Md45QaTgOuT^+8JJRat5m6D)+R&uics93Vq5`MyYcGv-4Se0NZ*J5`wt() z+xh+UBJ#~8F*t99nL^esB;j4QQF{b&TF#q}+AJ(RGBb^%4fz;m@5QT-a7u9yT{C_F zZgTX;3mD$aoSOLn(>L>JG3@E@c>qxuOF6pmwHwpPJEajYnm0z_!1~5&EWjcei~4sT ztH5+>BQO~;-(n0$+;1`EBQJ`varW7@$`aqElTubetqJoLQ*pxmifeb`1vu2)jZmsC ops*A<+JFpSZmeI?5@h~@2fL52e*gdg literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/control/multi-del.toml b/internal/toml-test/tests/invalid/control/multi-del.toml new file mode 100644 index 00000000..6629ae3b --- /dev/null +++ b/internal/toml-test/tests/invalid/control/multi-del.toml @@ -0,0 +1 @@ +multi-del = """null""" diff --git a/internal/toml-test/tests/invalid/control/multi-lf.toml b/internal/toml-test/tests/invalid/control/multi-lf.toml new file mode 100644 index 00000000..f207d33f --- /dev/null +++ b/internal/toml-test/tests/invalid/control/multi-lf.toml @@ -0,0 +1 @@ +multi-lf = """null""" diff --git a/internal/toml-test/tests/invalid/control/multi-null.toml b/internal/toml-test/tests/invalid/control/multi-null.toml new file mode 100644 index 0000000000000000000000000000000000000000..ac6cb46c006286cd6c9133c5029e17b2f3976db2 GIT binary patch literal 25 ccmc~T%_+&$%`45xQLt4|Qc?o37=Sbv0BuPJA^-pY literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/control/multi-us.toml b/internal/toml-test/tests/invalid/control/multi-us.toml new file mode 100644 index 00000000..b923ca9e --- /dev/null +++ b/internal/toml-test/tests/invalid/control/multi-us.toml @@ -0,0 +1 @@ +multi-us = """null""" diff --git a/internal/toml-test/tests/invalid/control/rawmulti-del.toml b/internal/toml-test/tests/invalid/control/rawmulti-del.toml new file mode 100644 index 00000000..17cde077 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/rawmulti-del.toml @@ -0,0 +1 @@ +rawmulti-del = '''null''' diff --git a/internal/toml-test/tests/invalid/control/rawmulti-lf.toml b/internal/toml-test/tests/invalid/control/rawmulti-lf.toml new file mode 100644 index 00000000..360d4898 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/rawmulti-lf.toml @@ -0,0 +1 @@ +rawmulti-lf = '''null''' diff --git a/internal/toml-test/tests/invalid/control/rawmulti-null.toml b/internal/toml-test/tests/invalid/control/rawmulti-null.toml new file mode 100644 index 0000000000000000000000000000000000000000..1b5bd092c5c54e408681c5bc215f34136f9d6029 GIT binary patch literal 28 fcmXR)EYB^?Daq8$E6vGKuvJi3R|l~efHW5Xkmm@B literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/control/rawmulti-us.toml b/internal/toml-test/tests/invalid/control/rawmulti-us.toml new file mode 100644 index 00000000..02514207 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/rawmulti-us.toml @@ -0,0 +1 @@ +rawmulti-us = '''null''' diff --git a/internal/toml-test/tests/invalid/control/rawstring-del.toml b/internal/toml-test/tests/invalid/control/rawstring-del.toml new file mode 100644 index 00000000..8d83ba8e --- /dev/null +++ b/internal/toml-test/tests/invalid/control/rawstring-del.toml @@ -0,0 +1 @@ +rawstring-del = 'null' diff --git a/internal/toml-test/tests/invalid/control/rawstring-lf.toml b/internal/toml-test/tests/invalid/control/rawstring-lf.toml new file mode 100644 index 00000000..237470ae --- /dev/null +++ b/internal/toml-test/tests/invalid/control/rawstring-lf.toml @@ -0,0 +1 @@ +rawstring-lf = 'null' diff --git a/internal/toml-test/tests/invalid/control/rawstring-null.toml b/internal/toml-test/tests/invalid/control/rawstring-null.toml new file mode 100644 index 0000000000000000000000000000000000000000..2d8d0b4cb8028a76db91a0455d23fc054577541b GIT binary patch literal 25 dcmXR)EH5r8%FIjG%`45xQLt4|2hj}bTmXCG2wDID literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/control/rawstring-us.toml b/internal/toml-test/tests/invalid/control/rawstring-us.toml new file mode 100644 index 00000000..76cb08c0 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/rawstring-us.toml @@ -0,0 +1 @@ +rawstring-us = 'null' diff --git a/internal/toml-test/tests/invalid/control/string-bs.toml b/internal/toml-test/tests/invalid/control/string-bs.toml new file mode 100644 index 00000000..0061c485 --- /dev/null +++ b/internal/toml-test/tests/invalid/control/string-bs.toml @@ -0,0 +1 @@ +string-bs = "backspace" diff --git a/internal/toml-test/tests/invalid/control/string-del.toml b/internal/toml-test/tests/invalid/control/string-del.toml new file mode 100644 index 00000000..bc0ec7fb --- /dev/null +++ b/internal/toml-test/tests/invalid/control/string-del.toml @@ -0,0 +1 @@ +string-del = "null" diff --git a/internal/toml-test/tests/invalid/control/string-lf.toml b/internal/toml-test/tests/invalid/control/string-lf.toml new file mode 100644 index 00000000..0cf9218d --- /dev/null +++ b/internal/toml-test/tests/invalid/control/string-lf.toml @@ -0,0 +1 @@ +string-lf = "null" diff --git a/internal/toml-test/tests/invalid/control/string-null.toml b/internal/toml-test/tests/invalid/control/string-null.toml new file mode 100644 index 0000000000000000000000000000000000000000..821c72c32cffdb36e3e090b510ad6699832fcd47 GIT binary patch literal 22 acmXReDay=C*Uc-<$x*OXPy*2mN?ZV3!UqNb literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/control/string-us.toml b/internal/toml-test/tests/invalid/control/string-us.toml new file mode 100644 index 00000000..af31f57b --- /dev/null +++ b/internal/toml-test/tests/invalid/control/string-us.toml @@ -0,0 +1 @@ +string-us = "null" diff --git a/internal/toml-test/tests/invalid/datetime/impossible-date.toml b/internal/toml-test/tests/invalid/datetime/impossible-date.toml new file mode 100644 index 00000000..78b55a39 --- /dev/null +++ b/internal/toml-test/tests/invalid/datetime/impossible-date.toml @@ -0,0 +1 @@ +d = 2006-01-50T00:00:00Z diff --git a/internal/toml-test/tests/invalid/datetime/no-leads-with-milli.toml b/internal/toml-test/tests/invalid/datetime/no-leads-with-milli.toml new file mode 100644 index 00000000..eef792f3 --- /dev/null +++ b/internal/toml-test/tests/invalid/datetime/no-leads-with-milli.toml @@ -0,0 +1 @@ +with-milli = 1987-07-5T17:45:00.12Z diff --git a/internal/toml-test/tests/invalid/datetime/no-leads.toml b/internal/toml-test/tests/invalid/datetime/no-leads.toml new file mode 100644 index 00000000..123f173b --- /dev/null +++ b/internal/toml-test/tests/invalid/datetime/no-leads.toml @@ -0,0 +1 @@ +no-leads = 1987-7-05T17:45:00Z diff --git a/internal/toml-test/tests/invalid/datetime/no-secs.toml b/internal/toml-test/tests/invalid/datetime/no-secs.toml new file mode 100644 index 00000000..ba939007 --- /dev/null +++ b/internal/toml-test/tests/invalid/datetime/no-secs.toml @@ -0,0 +1 @@ +no-secs = 1987-07-05T17:45Z diff --git a/internal/toml-test/tests/invalid/datetime/no-t.toml b/internal/toml-test/tests/invalid/datetime/no-t.toml new file mode 100644 index 00000000..617e3c56 --- /dev/null +++ b/internal/toml-test/tests/invalid/datetime/no-t.toml @@ -0,0 +1 @@ +no-t = 1987-07-0517:45:00Z diff --git a/internal/toml-test/tests/invalid/datetime/trailing-t.toml b/internal/toml-test/tests/invalid/datetime/trailing-t.toml new file mode 100644 index 00000000..9b731ff0 --- /dev/null +++ b/internal/toml-test/tests/invalid/datetime/trailing-t.toml @@ -0,0 +1 @@ +d = 2006-01-30T diff --git a/internal/toml-test/tests/invalid/encoding/bad-utf8-at-end.toml b/internal/toml-test/tests/invalid/encoding/bad-utf8-at-end.toml new file mode 100644 index 00000000..df5f0b06 --- /dev/null +++ b/internal/toml-test/tests/invalid/encoding/bad-utf8-at-end.toml @@ -0,0 +1,5 @@ +# There is a 0xda at after the quotes, and no EOL at the end of the file. +# +# This is a bit of an edge case: This indicates there should be two bytes +# (0b1101_1010) but there is no byte to follow because it's the end of the file. +x = """"""Ú \ No newline at end of file diff --git a/internal/toml-test/tests/invalid/encoding/bad-utf8-in-comment.toml b/internal/toml-test/tests/invalid/encoding/bad-utf8-in-comment.toml new file mode 100644 index 00000000..816fa469 --- /dev/null +++ b/internal/toml-test/tests/invalid/encoding/bad-utf8-in-comment.toml @@ -0,0 +1 @@ +# à diff --git a/internal/toml-test/tests/invalid/encoding/bad-utf8-in-string.toml b/internal/toml-test/tests/invalid/encoding/bad-utf8-in-string.toml new file mode 100644 index 00000000..6d376fb1 --- /dev/null +++ b/internal/toml-test/tests/invalid/encoding/bad-utf8-in-string.toml @@ -0,0 +1,2 @@ +# The following line contains an invalid UTF-8 sequence. +bad = "Ã" diff --git a/internal/toml-test/tests/invalid/encoding/bom-not-at-start-1.toml b/internal/toml-test/tests/invalid/encoding/bom-not-at-start-1.toml new file mode 100644 index 00000000..effe1f23 --- /dev/null +++ b/internal/toml-test/tests/invalid/encoding/bom-not-at-start-1.toml @@ -0,0 +1 @@ +bom-not-at-start ÿý diff --git a/internal/toml-test/tests/invalid/encoding/bom-not-at-start-2.toml b/internal/toml-test/tests/invalid/encoding/bom-not-at-start-2.toml new file mode 100644 index 00000000..71e52b41 --- /dev/null +++ b/internal/toml-test/tests/invalid/encoding/bom-not-at-start-2.toml @@ -0,0 +1 @@ +bom-not-at-start= ÿý diff --git a/internal/toml-test/tests/invalid/encoding/utf16-bom.toml b/internal/toml-test/tests/invalid/encoding/utf16-bom.toml new file mode 100644 index 0000000000000000000000000000000000000000..95b5f9608cb7861af19eecf94d67bdc6dc0e8f37 GIT binary patch literal 38 qcmezOpFx>HfgzM3gu#tLm%)(149F{I$YdyC$N;jO82lN08MpwPJqD-% literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/encoding/utf16.toml b/internal/toml-test/tests/invalid/encoding/utf16.toml new file mode 100644 index 0000000000000000000000000000000000000000..de3cbb2cb2ceb28abb334066ac58c8bc06fb0f91 GIT binary patch literal 42 ucmZQjW>8=VWe8z#W6)(VWH1Br${8{lN*FR2@)=5jv;u<@gFk~W0~Y{z>;?k> literal 0 HcmV?d00001 diff --git a/internal/toml-test/tests/invalid/float/double-point-1.toml b/internal/toml-test/tests/invalid/float/double-point-1.toml new file mode 100644 index 00000000..2105fa9b --- /dev/null +++ b/internal/toml-test/tests/invalid/float/double-point-1.toml @@ -0,0 +1 @@ +double-point-1 = 0..1 diff --git a/internal/toml-test/tests/invalid/float/double-point-2.toml b/internal/toml-test/tests/invalid/float/double-point-2.toml new file mode 100644 index 00000000..1ef3d0b7 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/double-point-2.toml @@ -0,0 +1 @@ +double-point-2 = 0.1.2 diff --git a/internal/toml-test/tests/invalid/float/exp-double-e-1.toml b/internal/toml-test/tests/invalid/float/exp-double-e-1.toml new file mode 100644 index 00000000..ee568ce8 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-double-e-1.toml @@ -0,0 +1 @@ +exp-double-e-1 = 1ee2 diff --git a/internal/toml-test/tests/invalid/float/exp-double-e-2.toml b/internal/toml-test/tests/invalid/float/exp-double-e-2.toml new file mode 100644 index 00000000..8fb01585 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-double-e-2.toml @@ -0,0 +1 @@ +exp-double-e-2 = 1e2e3 diff --git a/internal/toml-test/tests/invalid/float/exp-double-us.toml b/internal/toml-test/tests/invalid/float/exp-double-us.toml new file mode 100644 index 00000000..63f94e6c --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-double-us.toml @@ -0,0 +1 @@ +exp-double-us = 1e__23 diff --git a/internal/toml-test/tests/invalid/float/exp-leading-us.toml b/internal/toml-test/tests/invalid/float/exp-leading-us.toml new file mode 100644 index 00000000..1426f36a --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-leading-us.toml @@ -0,0 +1 @@ +exp-leading-us = 1e_23 diff --git a/internal/toml-test/tests/invalid/float/exp-point-1.toml b/internal/toml-test/tests/invalid/float/exp-point-1.toml new file mode 100644 index 00000000..569590bb --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-point-1.toml @@ -0,0 +1 @@ +exp-point-1 = 1e2.3 diff --git a/internal/toml-test/tests/invalid/float/exp-point-2.toml b/internal/toml-test/tests/invalid/float/exp-point-2.toml new file mode 100644 index 00000000..4a5e1d4d --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-point-2.toml @@ -0,0 +1 @@ +exp-point-2 = 1.e2 diff --git a/internal/toml-test/tests/invalid/float/exp-trailing-us.toml b/internal/toml-test/tests/invalid/float/exp-trailing-us.toml new file mode 100644 index 00000000..07c06413 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/exp-trailing-us.toml @@ -0,0 +1 @@ +exp-trailing-us = 1e_23_ diff --git a/internal/toml-test/tests/invalid/float/float.multi b/internal/toml-test/tests/invalid/float/float.multi new file mode 100644 index 00000000..07081954 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/float.multi @@ -0,0 +1,40 @@ +leading-zero = 03.14 +leading-zero-neg = -03.14 +leading-zero-plus = +03.14 + +leading-point = .12345 +leading-point-neg = -.12345 +leading-point-plus = +.12345 + +trailing-point = 1. +trailing-point-min = -1. +trailing-point-plus = +1. + +trailing-us = 1.2_ +leading-us = _1.2 +us-before-point = 1_.2 +us-after-point = 1._2 + +double-point-1 = 0..1 +double-point-2 = 0.1.2 + +exp-point-1 = 1e2.3 +exp-point-2 = 1.e2 + +exp-double-e-1 = 1ee2 +exp-double-e-2 = 1e2e3 + +exp-leading-us = 1e_23 +exp-trailing-us = 1e_23_ +exp-double-us = 1e__23 + +inf-incomplete-1 = in +inf-incomplete-2 = +in +inf-incomplete-3 = -in + +nan-incomplete-1 = na +nan-incomplete-2 = +na +nan-incomplete-3 = -na + +nan_underscore = na_n +inf_underscore = in_f diff --git a/internal/toml-test/tests/invalid/float/inf-incomplete-1.toml b/internal/toml-test/tests/invalid/float/inf-incomplete-1.toml new file mode 100644 index 00000000..2c9ef598 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/inf-incomplete-1.toml @@ -0,0 +1 @@ +inf-incomplete-1 = in diff --git a/internal/toml-test/tests/invalid/float/inf-incomplete-2.toml b/internal/toml-test/tests/invalid/float/inf-incomplete-2.toml new file mode 100644 index 00000000..afda7123 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/inf-incomplete-2.toml @@ -0,0 +1 @@ +inf-incomplete-2 = +in diff --git a/internal/toml-test/tests/invalid/float/inf-incomplete-3.toml b/internal/toml-test/tests/invalid/float/inf-incomplete-3.toml new file mode 100644 index 00000000..bd827386 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/inf-incomplete-3.toml @@ -0,0 +1 @@ +inf-incomplete-3 = -in diff --git a/internal/toml-test/tests/invalid/float/inf_underscore.toml b/internal/toml-test/tests/invalid/float/inf_underscore.toml new file mode 100644 index 00000000..8e6ab170 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/inf_underscore.toml @@ -0,0 +1 @@ +inf_underscore = in_f diff --git a/internal/toml-test/tests/invalid/float/leading-point-neg.toml b/internal/toml-test/tests/invalid/float/leading-point-neg.toml new file mode 100644 index 00000000..74c526fc --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-point-neg.toml @@ -0,0 +1 @@ +leading-point-neg = -.12345 diff --git a/internal/toml-test/tests/invalid/float/leading-point-plus.toml b/internal/toml-test/tests/invalid/float/leading-point-plus.toml new file mode 100644 index 00000000..85e23a28 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-point-plus.toml @@ -0,0 +1 @@ +leading-point-plus = +.12345 diff --git a/internal/toml-test/tests/invalid/float/leading-point.toml b/internal/toml-test/tests/invalid/float/leading-point.toml new file mode 100644 index 00000000..a3c29b97 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-point.toml @@ -0,0 +1 @@ +leading-point = .12345 diff --git a/internal/toml-test/tests/invalid/float/leading-us.toml b/internal/toml-test/tests/invalid/float/leading-us.toml new file mode 100644 index 00000000..fa94fd0f --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-us.toml @@ -0,0 +1 @@ +leading-us = _1.2 diff --git a/internal/toml-test/tests/invalid/float/leading-zero-neg.toml b/internal/toml-test/tests/invalid/float/leading-zero-neg.toml new file mode 100644 index 00000000..94a4e70a --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-zero-neg.toml @@ -0,0 +1 @@ +leading-zero-neg = -03.14 diff --git a/internal/toml-test/tests/invalid/float/leading-zero-plus.toml b/internal/toml-test/tests/invalid/float/leading-zero-plus.toml new file mode 100644 index 00000000..12bfd600 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-zero-plus.toml @@ -0,0 +1 @@ +leading-zero-plus = +03.14 diff --git a/internal/toml-test/tests/invalid/float/leading-zero.toml b/internal/toml-test/tests/invalid/float/leading-zero.toml new file mode 100644 index 00000000..551fb255 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/leading-zero.toml @@ -0,0 +1 @@ +leading-zero = 03.14 diff --git a/internal/toml-test/tests/invalid/float/nan-incomplete-1.toml b/internal/toml-test/tests/invalid/float/nan-incomplete-1.toml new file mode 100644 index 00000000..df2e2613 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/nan-incomplete-1.toml @@ -0,0 +1 @@ +nan-incomplete-1 = na diff --git a/internal/toml-test/tests/invalid/float/nan-incomplete-2.toml b/internal/toml-test/tests/invalid/float/nan-incomplete-2.toml new file mode 100644 index 00000000..6d2e8fb7 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/nan-incomplete-2.toml @@ -0,0 +1 @@ +nan-incomplete-2 = +na diff --git a/internal/toml-test/tests/invalid/float/nan-incomplete-3.toml b/internal/toml-test/tests/invalid/float/nan-incomplete-3.toml new file mode 100644 index 00000000..9d365acf --- /dev/null +++ b/internal/toml-test/tests/invalid/float/nan-incomplete-3.toml @@ -0,0 +1 @@ +nan-incomplete-3 = -na diff --git a/internal/toml-test/tests/invalid/float/nan_underscore.toml b/internal/toml-test/tests/invalid/float/nan_underscore.toml new file mode 100644 index 00000000..44c8bf16 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/nan_underscore.toml @@ -0,0 +1 @@ +nan_underscore = na_n diff --git a/internal/toml-test/tests/invalid/float/trailing-point-min.toml b/internal/toml-test/tests/invalid/float/trailing-point-min.toml new file mode 100644 index 00000000..48741e3b --- /dev/null +++ b/internal/toml-test/tests/invalid/float/trailing-point-min.toml @@ -0,0 +1 @@ +trailing-point-min = -1. diff --git a/internal/toml-test/tests/invalid/float/trailing-point-plus.toml b/internal/toml-test/tests/invalid/float/trailing-point-plus.toml new file mode 100644 index 00000000..99260390 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/trailing-point-plus.toml @@ -0,0 +1 @@ +trailing-point-plus = +1. diff --git a/internal/toml-test/tests/invalid/float/trailing-point.toml b/internal/toml-test/tests/invalid/float/trailing-point.toml new file mode 100644 index 00000000..76c95d91 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/trailing-point.toml @@ -0,0 +1 @@ +trailing-point = 1. diff --git a/internal/toml-test/tests/invalid/float/trailing-us.toml b/internal/toml-test/tests/invalid/float/trailing-us.toml new file mode 100644 index 00000000..ddfb7ba0 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/trailing-us.toml @@ -0,0 +1 @@ +trailing-us = 1.2_ diff --git a/internal/toml-test/tests/invalid/float/us-after-point.toml b/internal/toml-test/tests/invalid/float/us-after-point.toml new file mode 100644 index 00000000..7f15f570 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/us-after-point.toml @@ -0,0 +1 @@ +us-after-point = 1._2 diff --git a/internal/toml-test/tests/invalid/float/us-before-point.toml b/internal/toml-test/tests/invalid/float/us-before-point.toml new file mode 100644 index 00000000..c8edcbf0 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/us-before-point.toml @@ -0,0 +1 @@ +us-before-point = 1_.2 diff --git a/internal/toml-test/tests/invalid/inline-table/double-comma.toml b/internal/toml-test/tests/invalid/inline-table/double-comma.toml new file mode 100644 index 00000000..2d2913a3 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/double-comma.toml @@ -0,0 +1 @@ +t = {x=3,,y=4} diff --git a/internal/toml-test/tests/invalid/inline-table/empty.toml b/internal/toml-test/tests/invalid/inline-table/empty.toml new file mode 100644 index 00000000..ebbb0666 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/empty.toml @@ -0,0 +1 @@ +t = {,} diff --git a/internal/toml-test/tests/invalid/inline-table/linebreak-1.toml b/internal/toml-test/tests/invalid/inline-table/linebreak-1.toml new file mode 100644 index 00000000..0ae44b63 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/linebreak-1.toml @@ -0,0 +1,4 @@ +# No newlines are allowed between the curly braces unless they are valid within +# a value. +simple = { a = 1 +} diff --git a/internal/toml-test/tests/invalid/inline-table/linebreak-2.toml b/internal/toml-test/tests/invalid/inline-table/linebreak-2.toml new file mode 100644 index 00000000..5ea4eaf5 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/linebreak-2.toml @@ -0,0 +1,2 @@ +t = {a=1, +b=2} diff --git a/internal/toml-test/tests/invalid/inline-table/linebreak-3.toml b/internal/toml-test/tests/invalid/inline-table/linebreak-3.toml new file mode 100644 index 00000000..7f6e8924 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/linebreak-3.toml @@ -0,0 +1,2 @@ +t = {a=1 +,b=2} diff --git a/internal/toml-test/tests/invalid/inline-table/linebreak-4.toml b/internal/toml-test/tests/invalid/inline-table/linebreak-4.toml new file mode 100644 index 00000000..3f34e15c --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/linebreak-4.toml @@ -0,0 +1,4 @@ +json_like = { + first = "Tom", + last = "Preston-Werner" +} diff --git a/internal/toml-test/tests/invalid/inline-table/no-comma.toml b/internal/toml-test/tests/invalid/inline-table/no-comma.toml new file mode 100644 index 00000000..0a4083de --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/no-comma.toml @@ -0,0 +1 @@ +t = {x = 3 y = 4} diff --git a/internal/toml-test/tests/invalid/inline-table/trailing-comma.toml b/internal/toml-test/tests/invalid/inline-table/trailing-comma.toml new file mode 100644 index 00000000..6b67e020 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/trailing-comma.toml @@ -0,0 +1,3 @@ +# A terminating comma (also called trailing comma) is not permitted after the +# last key/value pair in an inline table +abc = { abc = 123, } diff --git a/internal/toml-test/tests/invalid/integer/capital-bin.toml b/internal/toml-test/tests/invalid/integer/capital-bin.toml new file mode 100644 index 00000000..bea4e5e2 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/capital-bin.toml @@ -0,0 +1 @@ +capital-bin = 0B0 diff --git a/internal/toml-test/tests/invalid/integer/capital-hex.toml b/internal/toml-test/tests/invalid/integer/capital-hex.toml new file mode 100644 index 00000000..bc064bb6 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/capital-hex.toml @@ -0,0 +1 @@ +capital-hex = 0X1 diff --git a/internal/toml-test/tests/invalid/integer/capital-oct.toml b/internal/toml-test/tests/invalid/integer/capital-oct.toml new file mode 100644 index 00000000..ea08a4da --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/capital-oct.toml @@ -0,0 +1 @@ +capital-oct = 0O0 diff --git a/internal/toml-test/tests/invalid/integer/double-sign-nex.toml b/internal/toml-test/tests/invalid/integer/double-sign-nex.toml new file mode 100644 index 00000000..ff014cf0 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/double-sign-nex.toml @@ -0,0 +1 @@ +double-sign-nex = --99 diff --git a/internal/toml-test/tests/invalid/integer/double-sign-plus.toml b/internal/toml-test/tests/invalid/integer/double-sign-plus.toml new file mode 100644 index 00000000..845ebb59 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/double-sign-plus.toml @@ -0,0 +1 @@ +double-sign-plus = ++99 diff --git a/internal/toml-test/tests/invalid/integer/double-us.toml b/internal/toml-test/tests/invalid/integer/double-us.toml new file mode 100644 index 00000000..cd00561f --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/double-us.toml @@ -0,0 +1 @@ +double-us = 1__23 diff --git a/internal/toml-test/tests/invalid/integer/integer.multi b/internal/toml-test/tests/invalid/integer/integer.multi new file mode 100644 index 00000000..eaf4b082 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/integer.multi @@ -0,0 +1,39 @@ +leading-zero-1 = 01 +leading-zero-2 = 00 +leading-zero-sign-1 = -01 +leading-zero-sign-2 = +01 + +double-sign-plus = ++99 +double-sign-nex = --99 + +negative-hex = -0xff +negative-bin = -0b11010110 +negative-oct = -0o99 + +positive-hex = +0xff +positive-bin = +0b11010110 +positive-oct = +0o99 + +trailing-us = 123_ +leading-us = _123 +double-us = 1__23 + +us-after-hex = 0x_1 +us-after-oct = 0o_1 +us-after-bin = 0b_1 + +trailing-us-hex = 0x1_ +trailing-us-oct = 0o1_ +trailing-us-bin = 0b1_ + +leading-us-hex = _0o1 +leading-us-oct = _0o1 +leading-us-bin = _0o1 + +invalid-hex = 0xaafz +invalid-oct = 0o778 +invalid-bin = 0b0012 + +capital-hex = 0X1 +capital-oct = 0O0 +capital-bin = 0B0 diff --git a/internal/toml-test/tests/invalid/integer/invalid-bin.toml b/internal/toml-test/tests/invalid/integer/invalid-bin.toml new file mode 100644 index 00000000..d0182581 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/invalid-bin.toml @@ -0,0 +1 @@ +invalid-bin = 0b0012 diff --git a/internal/toml-test/tests/invalid/integer/invalid-hex.toml b/internal/toml-test/tests/invalid/integer/invalid-hex.toml new file mode 100644 index 00000000..7cc0e855 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/invalid-hex.toml @@ -0,0 +1 @@ +invalid-hex = 0xaafz diff --git a/internal/toml-test/tests/invalid/integer/invalid-oct.toml b/internal/toml-test/tests/invalid/integer/invalid-oct.toml new file mode 100644 index 00000000..03181b1a --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/invalid-oct.toml @@ -0,0 +1 @@ +invalid-oct = 0o778 diff --git a/internal/toml-test/tests/invalid/integer/leading-us-bin.toml b/internal/toml-test/tests/invalid/integer/leading-us-bin.toml new file mode 100644 index 00000000..8885c031 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-us-bin.toml @@ -0,0 +1 @@ +leading-us-bin = _0o1 diff --git a/internal/toml-test/tests/invalid/integer/leading-us-hex.toml b/internal/toml-test/tests/invalid/integer/leading-us-hex.toml new file mode 100644 index 00000000..9f193f80 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-us-hex.toml @@ -0,0 +1 @@ +leading-us-hex = _0o1 diff --git a/internal/toml-test/tests/invalid/integer/leading-us-oct.toml b/internal/toml-test/tests/invalid/integer/leading-us-oct.toml new file mode 100644 index 00000000..a717f1c8 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-us-oct.toml @@ -0,0 +1 @@ +leading-us-oct = _0o1 diff --git a/internal/toml-test/tests/invalid/integer/leading-us.toml b/internal/toml-test/tests/invalid/integer/leading-us.toml new file mode 100644 index 00000000..d059f50a --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-us.toml @@ -0,0 +1 @@ +leading-us = _123 diff --git a/internal/toml-test/tests/invalid/integer/leading-zero-1.toml b/internal/toml-test/tests/invalid/integer/leading-zero-1.toml new file mode 100644 index 00000000..eba6bda3 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-zero-1.toml @@ -0,0 +1 @@ +leading-zero-1 = 01 diff --git a/internal/toml-test/tests/invalid/integer/leading-zero-2.toml b/internal/toml-test/tests/invalid/integer/leading-zero-2.toml new file mode 100644 index 00000000..436af565 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-zero-2.toml @@ -0,0 +1 @@ +leading-zero-2 = 00 diff --git a/internal/toml-test/tests/invalid/integer/leading-zero-sign-1.toml b/internal/toml-test/tests/invalid/integer/leading-zero-sign-1.toml new file mode 100644 index 00000000..1f15a9da --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-zero-sign-1.toml @@ -0,0 +1 @@ +leading-zero-sign-1 = -01 diff --git a/internal/toml-test/tests/invalid/integer/leading-zero-sign-2.toml b/internal/toml-test/tests/invalid/integer/leading-zero-sign-2.toml new file mode 100644 index 00000000..fa259c3c --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/leading-zero-sign-2.toml @@ -0,0 +1 @@ +leading-zero-sign-2 = +01 diff --git a/internal/toml-test/tests/invalid/integer/negative-bin.toml b/internal/toml-test/tests/invalid/integer/negative-bin.toml new file mode 100644 index 00000000..948b2367 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/negative-bin.toml @@ -0,0 +1 @@ +negative-bin = -0b11010110 diff --git a/internal/toml-test/tests/invalid/integer/negative-hex.toml b/internal/toml-test/tests/invalid/integer/negative-hex.toml new file mode 100644 index 00000000..67c31ea4 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/negative-hex.toml @@ -0,0 +1 @@ +negative-hex = -0xff diff --git a/internal/toml-test/tests/invalid/integer/negative-oct.toml b/internal/toml-test/tests/invalid/integer/negative-oct.toml new file mode 100644 index 00000000..b0c5ab0d --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/negative-oct.toml @@ -0,0 +1 @@ +negative-oct = -0o99 diff --git a/internal/toml-test/tests/invalid/integer/positive-bin.toml b/internal/toml-test/tests/invalid/integer/positive-bin.toml new file mode 100644 index 00000000..7d6de651 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/positive-bin.toml @@ -0,0 +1 @@ +positive-bin = +0b11010110 diff --git a/internal/toml-test/tests/invalid/integer/positive-hex.toml b/internal/toml-test/tests/invalid/integer/positive-hex.toml new file mode 100644 index 00000000..bd503aad --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/positive-hex.toml @@ -0,0 +1 @@ +positive-hex = +0xff diff --git a/internal/toml-test/tests/invalid/integer/positive-oct.toml b/internal/toml-test/tests/invalid/integer/positive-oct.toml new file mode 100644 index 00000000..d77aa521 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/positive-oct.toml @@ -0,0 +1 @@ +positive-oct = +0o99 diff --git a/internal/toml-test/tests/invalid/integer/text-after-integer.toml b/internal/toml-test/tests/invalid/integer/text-after-integer.toml new file mode 100644 index 00000000..42de7aff --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/text-after-integer.toml @@ -0,0 +1 @@ +answer = 42 the ultimate answer? diff --git a/internal/toml-test/tests/invalid/integer/trailing-us-bin.toml b/internal/toml-test/tests/invalid/integer/trailing-us-bin.toml new file mode 100644 index 00000000..9a0b5741 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/trailing-us-bin.toml @@ -0,0 +1 @@ +trailing-us-bin = 0b1_ diff --git a/internal/toml-test/tests/invalid/integer/trailing-us-hex.toml b/internal/toml-test/tests/invalid/integer/trailing-us-hex.toml new file mode 100644 index 00000000..2a964550 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/trailing-us-hex.toml @@ -0,0 +1 @@ +trailing-us-hex = 0x1_ diff --git a/internal/toml-test/tests/invalid/integer/trailing-us-oct.toml b/internal/toml-test/tests/invalid/integer/trailing-us-oct.toml new file mode 100644 index 00000000..d28e8bca --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/trailing-us-oct.toml @@ -0,0 +1 @@ +trailing-us-oct = 0o1_ diff --git a/internal/toml-test/tests/invalid/integer/trailing-us.toml b/internal/toml-test/tests/invalid/integer/trailing-us.toml new file mode 100644 index 00000000..e11e8ff6 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/trailing-us.toml @@ -0,0 +1 @@ +trailing-us = 123_ diff --git a/internal/toml-test/tests/invalid/integer/us-after-bin.toml b/internal/toml-test/tests/invalid/integer/us-after-bin.toml new file mode 100644 index 00000000..61dd895d --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/us-after-bin.toml @@ -0,0 +1 @@ +us-after-bin = 0b_1 diff --git a/internal/toml-test/tests/invalid/integer/us-after-hex.toml b/internal/toml-test/tests/invalid/integer/us-after-hex.toml new file mode 100644 index 00000000..200220ad --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/us-after-hex.toml @@ -0,0 +1 @@ +us-after-hex = 0x_1 diff --git a/internal/toml-test/tests/invalid/integer/us-after-oct.toml b/internal/toml-test/tests/invalid/integer/us-after-oct.toml new file mode 100644 index 00000000..23f53003 --- /dev/null +++ b/internal/toml-test/tests/invalid/integer/us-after-oct.toml @@ -0,0 +1 @@ +us-after-oct = 0o_1 diff --git a/internal/toml-test/tests/invalid/key/after-array.toml b/internal/toml-test/tests/invalid/key/after-array.toml new file mode 100644 index 00000000..5c1a1b0a --- /dev/null +++ b/internal/toml-test/tests/invalid/key/after-array.toml @@ -0,0 +1 @@ +[[agencies]] owner = "S Cjelli" diff --git a/internal/toml-test/tests/invalid/key/after-table.toml b/internal/toml-test/tests/invalid/key/after-table.toml new file mode 100644 index 00000000..68867842 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/after-table.toml @@ -0,0 +1 @@ +[error] this = "should not be here" diff --git a/internal/toml-test/tests/invalid/key/after-value.toml b/internal/toml-test/tests/invalid/key/after-value.toml new file mode 100644 index 00000000..e05c47c2 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/after-value.toml @@ -0,0 +1 @@ +first = "Tom" last = "Preston-Werner" # INVALID diff --git a/internal/toml-test/tests/invalid/key/bare-invalid-character.toml b/internal/toml-test/tests/invalid/key/bare-invalid-character.toml new file mode 100644 index 00000000..e50dbe38 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/bare-invalid-character.toml @@ -0,0 +1 @@ +bare!key = 123 diff --git a/internal/toml-test/tests/invalid/key/dotted-redefine-table.toml b/internal/toml-test/tests/invalid/key/dotted-redefine-table.toml new file mode 100644 index 00000000..55e25ac0 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/dotted-redefine-table.toml @@ -0,0 +1,4 @@ +# Defined a.b as int +a.b = 1 +# Tries to access it as table: error +a.b.c = 2 diff --git a/internal/toml-test/tests/invalid/key/duplicate-keys.toml b/internal/toml-test/tests/invalid/key/duplicate-keys.toml new file mode 100644 index 00000000..9b5aee0e --- /dev/null +++ b/internal/toml-test/tests/invalid/key/duplicate-keys.toml @@ -0,0 +1,2 @@ +dupe = false +dupe = true diff --git a/internal/toml-test/tests/invalid/key/duplicate.toml b/internal/toml-test/tests/invalid/key/duplicate.toml new file mode 100644 index 00000000..7847bd40 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/duplicate.toml @@ -0,0 +1,3 @@ +# DO NOT DO THIS +name = "Tom" +name = "Pradyun" diff --git a/internal/toml-test/tests/invalid/key/empty.toml b/internal/toml-test/tests/invalid/key/empty.toml new file mode 100644 index 00000000..09f998f4 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/empty.toml @@ -0,0 +1 @@ + = 1 diff --git a/internal/toml-test/tests/invalid/key/escape.toml b/internal/toml-test/tests/invalid/key/escape.toml new file mode 100644 index 00000000..cdb8f4d6 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/escape.toml @@ -0,0 +1 @@ +\u00c0 = "latin capital letter A with grave" diff --git a/internal/toml-test/tests/invalid/key/hash.toml b/internal/toml-test/tests/invalid/key/hash.toml new file mode 100644 index 00000000..e321b1fb --- /dev/null +++ b/internal/toml-test/tests/invalid/key/hash.toml @@ -0,0 +1 @@ +a# = 1 diff --git a/internal/toml-test/tests/invalid/key/multiline.toml b/internal/toml-test/tests/invalid/key/multiline.toml new file mode 100644 index 00000000..31ff67e4 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/multiline.toml @@ -0,0 +1,2 @@ +"""long +key""" = 1 diff --git a/internal/toml-test/tests/invalid/key/newline.toml b/internal/toml-test/tests/invalid/key/newline.toml new file mode 100644 index 00000000..24acaa1b --- /dev/null +++ b/internal/toml-test/tests/invalid/key/newline.toml @@ -0,0 +1,2 @@ +barekey + = 123 diff --git a/internal/toml-test/tests/invalid/key/no-eol.toml b/internal/toml-test/tests/invalid/key/no-eol.toml new file mode 100644 index 00000000..3c58eee1 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/no-eol.toml @@ -0,0 +1 @@ +a = 1 b = 2 diff --git a/internal/toml-test/tests/invalid/key/open-bracket.toml b/internal/toml-test/tests/invalid/key/open-bracket.toml new file mode 100644 index 00000000..f0aeb16e --- /dev/null +++ b/internal/toml-test/tests/invalid/key/open-bracket.toml @@ -0,0 +1 @@ +[abc = 1 diff --git a/internal/toml-test/tests/invalid/key/partial-quoted.toml b/internal/toml-test/tests/invalid/key/partial-quoted.toml new file mode 100644 index 00000000..e491a2f1 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/partial-quoted.toml @@ -0,0 +1 @@ +partial"quoted" = 5 diff --git a/internal/toml-test/tests/invalid/key/single-open-bracket.toml b/internal/toml-test/tests/invalid/key/single-open-bracket.toml new file mode 100644 index 00000000..558ed37d --- /dev/null +++ b/internal/toml-test/tests/invalid/key/single-open-bracket.toml @@ -0,0 +1 @@ +[ diff --git a/internal/toml-test/tests/invalid/key/space.toml b/internal/toml-test/tests/invalid/key/space.toml new file mode 100644 index 00000000..7c22703e --- /dev/null +++ b/internal/toml-test/tests/invalid/key/space.toml @@ -0,0 +1 @@ +a b = 1 diff --git a/internal/toml-test/tests/invalid/key/special-character.toml b/internal/toml-test/tests/invalid/key/special-character.toml new file mode 100644 index 00000000..bc181a5c --- /dev/null +++ b/internal/toml-test/tests/invalid/key/special-character.toml @@ -0,0 +1 @@ +μ = "greek small letter mu" diff --git a/internal/toml-test/tests/invalid/key/start-bracket.toml b/internal/toml-test/tests/invalid/key/start-bracket.toml new file mode 100644 index 00000000..e0597ae1 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/start-bracket.toml @@ -0,0 +1,3 @@ +[a] +[xyz = 5 +[b] diff --git a/internal/toml-test/tests/invalid/key/two-equals.toml b/internal/toml-test/tests/invalid/key/two-equals.toml new file mode 100644 index 00000000..25a03789 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/two-equals.toml @@ -0,0 +1 @@ +key= = 1 diff --git a/internal/toml-test/tests/invalid/key/two-equals2.toml b/internal/toml-test/tests/invalid/key/two-equals2.toml new file mode 100644 index 00000000..c5f2de8b --- /dev/null +++ b/internal/toml-test/tests/invalid/key/two-equals2.toml @@ -0,0 +1 @@ +a==1 diff --git a/internal/toml-test/tests/invalid/key/two-equals3.toml b/internal/toml-test/tests/invalid/key/two-equals3.toml new file mode 100644 index 00000000..eb203729 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/two-equals3.toml @@ -0,0 +1 @@ +a=b=1 diff --git a/internal/toml-test/tests/invalid/key/without-value-1.toml b/internal/toml-test/tests/invalid/key/without-value-1.toml new file mode 100644 index 00000000..06bfde49 --- /dev/null +++ b/internal/toml-test/tests/invalid/key/without-value-1.toml @@ -0,0 +1 @@ +key diff --git a/internal/toml-test/tests/invalid/key/without-value-2.toml b/internal/toml-test/tests/invalid/key/without-value-2.toml new file mode 100644 index 00000000..ca6d7eba --- /dev/null +++ b/internal/toml-test/tests/invalid/key/without-value-2.toml @@ -0,0 +1 @@ +key = diff --git a/internal/toml-test/tests/invalid/string/bad-byte-escape.toml b/internal/toml-test/tests/invalid/string/bad-byte-escape.toml new file mode 100644 index 00000000..4c7be59f --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-byte-escape.toml @@ -0,0 +1 @@ +naughty = "\xAg" diff --git a/internal/toml-test/tests/invalid/string/bad-codepoint.toml b/internal/toml-test/tests/invalid/string/bad-codepoint.toml new file mode 100644 index 00000000..592db75b --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-codepoint.toml @@ -0,0 +1 @@ +invalid-codepoint = "This string contains a non scalar unicode codepoint \uD801" diff --git a/internal/toml-test/tests/invalid/string/bad-concat.toml b/internal/toml-test/tests/invalid/string/bad-concat.toml new file mode 100644 index 00000000..fc6d3c9c --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-concat.toml @@ -0,0 +1 @@ +no_concat = "first" "second" diff --git a/internal/toml-test/tests/invalid/string/bad-escape.toml b/internal/toml-test/tests/invalid/string/bad-escape.toml new file mode 100644 index 00000000..60acb0cc --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-escape.toml @@ -0,0 +1 @@ +invalid-escape = "This string has a bad \a escape character." diff --git a/internal/toml-test/tests/invalid/string/bad-multiline.toml b/internal/toml-test/tests/invalid/string/bad-multiline.toml new file mode 100644 index 00000000..786046b5 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-multiline.toml @@ -0,0 +1,2 @@ +multi = "first line +second line" diff --git a/internal/toml-test/tests/invalid/string/bad-slash-escape.toml b/internal/toml-test/tests/invalid/string/bad-slash-escape.toml new file mode 100644 index 00000000..154abadd --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-slash-escape.toml @@ -0,0 +1 @@ +invalid-escape = "This string has a bad \/ escape character." diff --git a/internal/toml-test/tests/invalid/string/bad-uni-esc.toml b/internal/toml-test/tests/invalid/string/bad-uni-esc.toml new file mode 100644 index 00000000..9eae4ab9 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/bad-uni-esc.toml @@ -0,0 +1 @@ +str = "val\ue" diff --git a/internal/toml-test/tests/invalid/string/basic-byte-escapes.toml b/internal/toml-test/tests/invalid/string/basic-byte-escapes.toml new file mode 100644 index 00000000..e94452a8 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-byte-escapes.toml @@ -0,0 +1 @@ +answer = "\x33" diff --git a/internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-1.toml b/internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-1.toml new file mode 100644 index 00000000..b27e203c --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-1.toml @@ -0,0 +1 @@ +a = """\UFFFFFFFF""" diff --git a/internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-2.toml b/internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-2.toml new file mode 100644 index 00000000..17a9361b --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-multiline-out-of-range-unicode-escape-2.toml @@ -0,0 +1 @@ +a = """\U00D80000""" diff --git a/internal/toml-test/tests/invalid/string/basic-multiline-quotes.toml b/internal/toml-test/tests/invalid/string/basic-multiline-quotes.toml new file mode 100644 index 00000000..02ebf13a --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-multiline-quotes.toml @@ -0,0 +1 @@ +str5 = """Here are three quotation marks: """.""" diff --git a/internal/toml-test/tests/invalid/string/basic-multiline-unknown-escape.toml b/internal/toml-test/tests/invalid/string/basic-multiline-unknown-escape.toml new file mode 100644 index 00000000..35c5cc5e --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-multiline-unknown-escape.toml @@ -0,0 +1 @@ +a = """\@""" diff --git a/internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-1.toml b/internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-1.toml new file mode 100644 index 00000000..ada1f557 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-1.toml @@ -0,0 +1 @@ +a = "\UFFFFFFFF" diff --git a/internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-2.toml b/internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-2.toml new file mode 100644 index 00000000..d4833b3d --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-out-of-range-unicode-escape-2.toml @@ -0,0 +1 @@ +a = "\U00D80000" diff --git a/internal/toml-test/tests/invalid/string/basic-unknown-escape.toml b/internal/toml-test/tests/invalid/string/basic-unknown-escape.toml new file mode 100644 index 00000000..381dd858 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/basic-unknown-escape.toml @@ -0,0 +1 @@ +a = "\@" diff --git a/internal/toml-test/tests/invalid/string/literal-multiline-quotes-1.toml b/internal/toml-test/tests/invalid/string/literal-multiline-quotes-1.toml new file mode 100644 index 00000000..9cfb7635 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/literal-multiline-quotes-1.toml @@ -0,0 +1,2 @@ +a = '''6 apostrophes: '''''' + diff --git a/internal/toml-test/tests/invalid/string/literal-multiline-quotes-2.toml b/internal/toml-test/tests/invalid/string/literal-multiline-quotes-2.toml new file mode 100644 index 00000000..9924236e --- /dev/null +++ b/internal/toml-test/tests/invalid/string/literal-multiline-quotes-2.toml @@ -0,0 +1 @@ +a = '''15 apostrophes: '''''''''''''''''' diff --git a/internal/toml-test/tests/invalid/string/missing-quotes.toml b/internal/toml-test/tests/invalid/string/missing-quotes.toml new file mode 100644 index 00000000..22927931 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/missing-quotes.toml @@ -0,0 +1 @@ +name = value diff --git a/internal/toml-test/tests/invalid/string/multiline-escape-space.toml b/internal/toml-test/tests/invalid/string/multiline-escape-space.toml new file mode 100644 index 00000000..13570d3b --- /dev/null +++ b/internal/toml-test/tests/invalid/string/multiline-escape-space.toml @@ -0,0 +1,3 @@ +a = """ + foo \ \n + bar""" diff --git a/internal/toml-test/tests/invalid/string/multiline-no-close-2.toml b/internal/toml-test/tests/invalid/string/multiline-no-close-2.toml new file mode 100644 index 00000000..f4694020 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/multiline-no-close-2.toml @@ -0,0 +1 @@ +x=""" diff --git a/internal/toml-test/tests/invalid/string/multiline-no-close.toml b/internal/toml-test/tests/invalid/string/multiline-no-close.toml new file mode 100644 index 00000000..4ca95971 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/multiline-no-close.toml @@ -0,0 +1,2 @@ +invalid = """ + this will fail diff --git a/internal/toml-test/tests/invalid/string/multiline-quotes-1.toml b/internal/toml-test/tests/invalid/string/multiline-quotes-1.toml new file mode 100644 index 00000000..9f7a42b7 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/multiline-quotes-1.toml @@ -0,0 +1 @@ +a = """6 quotes: """""" diff --git a/internal/toml-test/tests/invalid/string/multiline-quotes-2.toml b/internal/toml-test/tests/invalid/string/multiline-quotes-2.toml new file mode 100644 index 00000000..9f7a42b7 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/multiline-quotes-2.toml @@ -0,0 +1 @@ +a = """6 quotes: """""" diff --git a/internal/toml-test/tests/invalid/string/no-close.toml b/internal/toml-test/tests/invalid/string/no-close.toml new file mode 100644 index 00000000..0c292fca --- /dev/null +++ b/internal/toml-test/tests/invalid/string/no-close.toml @@ -0,0 +1 @@ +no-ending-quote = "One time, at band camp diff --git a/internal/toml-test/tests/invalid/string/text-after-string.toml b/internal/toml-test/tests/invalid/string/text-after-string.toml new file mode 100644 index 00000000..c92a6f11 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/text-after-string.toml @@ -0,0 +1 @@ +string = "Is there life after strings?" No. diff --git a/internal/toml-test/tests/invalid/string/wrong-close.toml b/internal/toml-test/tests/invalid/string/wrong-close.toml new file mode 100644 index 00000000..0f5c8011 --- /dev/null +++ b/internal/toml-test/tests/invalid/string/wrong-close.toml @@ -0,0 +1 @@ +bad-ending-quote = "double and single' diff --git a/internal/toml-test/tests/invalid/table/array-empty.toml b/internal/toml-test/tests/invalid/table/array-empty.toml new file mode 100644 index 00000000..a470ca33 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/array-empty.toml @@ -0,0 +1,2 @@ +[[]] +name = "Born to Run" diff --git a/internal/toml-test/tests/invalid/table/array-implicit.toml b/internal/toml-test/tests/invalid/table/array-implicit.toml new file mode 100644 index 00000000..05f2507e --- /dev/null +++ b/internal/toml-test/tests/invalid/table/array-implicit.toml @@ -0,0 +1,14 @@ +# This test is a bit tricky. It should fail because the first use of +# `[[albums.songs]]` without first declaring `albums` implies that `albums` +# must be a table. The alternative would be quite weird. Namely, it wouldn't +# comply with the TOML spec: "Each double-bracketed sub-table will belong to +# the most *recently* defined table element *above* it." +# +# This is in contrast to the *valid* test, table-array-implicit where +# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared +# later. (Although, `[albums]` could be.) +[[albums.songs]] +name = "Glory Days" + +[[albums]] +name = "Born in the USA" diff --git a/internal/toml-test/tests/invalid/table/array-missing-bracket.toml b/internal/toml-test/tests/invalid/table/array-missing-bracket.toml new file mode 100644 index 00000000..39c73b05 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/array-missing-bracket.toml @@ -0,0 +1,2 @@ +[[albums] +name = "Born to Run" diff --git a/internal/toml-test/tests/invalid/table/duplicate-key-table.toml b/internal/toml-test/tests/invalid/table/duplicate-key-table.toml new file mode 100644 index 00000000..cedf05fc --- /dev/null +++ b/internal/toml-test/tests/invalid/table/duplicate-key-table.toml @@ -0,0 +1,5 @@ +[fruit] +type = "apple" + +[fruit.type] +apple = "yes" diff --git a/internal/toml-test/tests/invalid/table/duplicate-table-array.toml b/internal/toml-test/tests/invalid/table/duplicate-table-array.toml new file mode 100644 index 00000000..a1d87059 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/duplicate-table-array.toml @@ -0,0 +1,2 @@ +[tbl] +[[tbl]] diff --git a/internal/toml-test/tests/invalid/table/duplicate-table-array2.toml b/internal/toml-test/tests/invalid/table/duplicate-table-array2.toml new file mode 100644 index 00000000..72eacbd1 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/duplicate-table-array2.toml @@ -0,0 +1,2 @@ +[[tbl]] +[tbl] diff --git a/internal/toml-test/tests/invalid/table/duplicate.toml b/internal/toml-test/tests/invalid/table/duplicate.toml new file mode 100644 index 00000000..73ef1cc7 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/duplicate.toml @@ -0,0 +1,5 @@ +[a] +b = 1 + +[a] +c = 2 diff --git a/internal/toml-test/tests/invalid/table/empty-implicit-table.toml b/internal/toml-test/tests/invalid/table/empty-implicit-table.toml new file mode 100644 index 00000000..0cc36d0d --- /dev/null +++ b/internal/toml-test/tests/invalid/table/empty-implicit-table.toml @@ -0,0 +1 @@ +[naughty..naughty] diff --git a/internal/toml-test/tests/invalid/table/empty.toml b/internal/toml-test/tests/invalid/table/empty.toml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/internal/toml-test/tests/invalid/table/empty.toml @@ -0,0 +1 @@ +[] diff --git a/internal/toml-test/tests/invalid/table/equals-sign.toml b/internal/toml-test/tests/invalid/table/equals-sign.toml new file mode 100644 index 00000000..eb5e742f --- /dev/null +++ b/internal/toml-test/tests/invalid/table/equals-sign.toml @@ -0,0 +1 @@ +[name=bad] diff --git a/internal/toml-test/tests/invalid/table/llbrace.toml b/internal/toml-test/tests/invalid/table/llbrace.toml new file mode 100644 index 00000000..047978e5 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/llbrace.toml @@ -0,0 +1 @@ +[ [table]] diff --git a/internal/toml-test/tests/invalid/table/nested-brackets-close.toml b/internal/toml-test/tests/invalid/table/nested-brackets-close.toml new file mode 100644 index 00000000..c8b5a678 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/nested-brackets-close.toml @@ -0,0 +1,2 @@ +[a]b] +zyx = 42 diff --git a/internal/toml-test/tests/invalid/table/nested-brackets-open.toml b/internal/toml-test/tests/invalid/table/nested-brackets-open.toml new file mode 100644 index 00000000..246d7e91 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/nested-brackets-open.toml @@ -0,0 +1,2 @@ +[a[b] +zyx = 42 diff --git a/internal/toml-test/tests/invalid/table/quoted-no-close.toml b/internal/toml-test/tests/invalid/table/quoted-no-close.toml new file mode 100644 index 00000000..6e7c1a1e --- /dev/null +++ b/internal/toml-test/tests/invalid/table/quoted-no-close.toml @@ -0,0 +1,2 @@ +["where will it end] +name = value diff --git a/internal/toml-test/tests/invalid/table/redefine.toml b/internal/toml-test/tests/invalid/table/redefine.toml new file mode 100644 index 00000000..fc23bf7d --- /dev/null +++ b/internal/toml-test/tests/invalid/table/redefine.toml @@ -0,0 +1,6 @@ +# Define b as int, and try to use it as a table: error +[a] +b = 1 + +[a.b] +c = 2 diff --git a/internal/toml-test/tests/invalid/table/rrbrace.toml b/internal/toml-test/tests/invalid/table/rrbrace.toml new file mode 100644 index 00000000..3a4dee47 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/rrbrace.toml @@ -0,0 +1 @@ +[[table] ] diff --git a/internal/toml-test/tests/invalid/table/text-after-table.toml b/internal/toml-test/tests/invalid/table/text-after-table.toml new file mode 100644 index 00000000..87da9db2 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/text-after-table.toml @@ -0,0 +1 @@ +[error] this shouldn't be here diff --git a/internal/toml-test/tests/invalid/table/whitespace.toml b/internal/toml-test/tests/invalid/table/whitespace.toml new file mode 100644 index 00000000..0a6a6a69 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/whitespace.toml @@ -0,0 +1 @@ +[invalid key] diff --git a/internal/toml-test/tests/invalid/table/with-pound.toml b/internal/toml-test/tests/invalid/table/with-pound.toml new file mode 100644 index 00000000..e7b777ec --- /dev/null +++ b/internal/toml-test/tests/invalid/table/with-pound.toml @@ -0,0 +1,2 @@ +[key#group] +answer = 42 diff --git a/internal/toml-test/tests/valid/array/array.json b/internal/toml-test/tests/valid/array/array.json new file mode 100644 index 00000000..4e9d45b8 --- /dev/null +++ b/internal/toml-test/tests/valid/array/array.json @@ -0,0 +1,68 @@ +{ + "comments": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ], + "dates": [ + { + "type": "datetime", + "value": "1987-07-05T17:45:00Z" + }, + { + "type": "datetime", + "value": "1979-05-27T07:32:00Z" + }, + { + "type": "datetime", + "value": "2006-06-01T11:00:00Z" + } + ], + "floats": [ + { + "type": "float", + "value": "1.1" + }, + { + "type": "float", + "value": "2.1" + }, + { + "type": "float", + "value": "3.1" + } + ], + "ints": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + { + "type": "integer", + "value": "3" + } + ], + "strings": [ + { + "type": "string", + "value": "a" + }, + { + "type": "string", + "value": "b" + }, + { + "type": "string", + "value": "c" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/array.toml b/internal/toml-test/tests/valid/array/array.toml new file mode 100644 index 00000000..ab884652 --- /dev/null +++ b/internal/toml-test/tests/valid/array/array.toml @@ -0,0 +1,12 @@ +ints = [1, 2, 3, ] +floats = [1.1, 2.1, 3.1] +strings = ["a", "b", "c"] +dates = [ + 1987-07-05T17:45:00Z, + 1979-05-27T07:32:00Z, + 2006-06-01T11:00:00Z, +] +comments = [ + 1, + 2, #this is ok +] diff --git a/internal/toml-test/tests/valid/array/bool.json b/internal/toml-test/tests/valid/array/bool.json new file mode 100644 index 00000000..7cede3fc --- /dev/null +++ b/internal/toml-test/tests/valid/array/bool.json @@ -0,0 +1,12 @@ +{ + "a": [ + { + "type": "bool", + "value": "true" + }, + { + "type": "bool", + "value": "false" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/bool.toml b/internal/toml-test/tests/valid/array/bool.toml new file mode 100644 index 00000000..d2010c58 --- /dev/null +++ b/internal/toml-test/tests/valid/array/bool.toml @@ -0,0 +1 @@ +a = [true, false] diff --git a/internal/toml-test/tests/valid/array/empty.json b/internal/toml-test/tests/valid/array/empty.json new file mode 100644 index 00000000..7b1ca0cf --- /dev/null +++ b/internal/toml-test/tests/valid/array/empty.json @@ -0,0 +1,11 @@ +{ + "thevoid": [ + [ + [ + [ + [] + ] + ] + ] + ] +} diff --git a/internal/toml-test/tests/valid/array/empty.toml b/internal/toml-test/tests/valid/array/empty.toml new file mode 100644 index 00000000..fa58dc63 --- /dev/null +++ b/internal/toml-test/tests/valid/array/empty.toml @@ -0,0 +1 @@ +thevoid = [[[[[]]]]] diff --git a/internal/toml-test/tests/valid/array/hetergeneous.json b/internal/toml-test/tests/valid/array/hetergeneous.json new file mode 100644 index 00000000..751b6244 --- /dev/null +++ b/internal/toml-test/tests/valid/array/hetergeneous.json @@ -0,0 +1,34 @@ +{ + "mixed": [ + [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ], + [ + { + "type": "string", + "value": "a" + }, + { + "type": "string", + "value": "b" + } + ], + [ + { + "type": "float", + "value": "1.1" + }, + { + "type": "float", + "value": "2.1" + } + ] + ] +} diff --git a/internal/toml-test/tests/valid/array/hetergeneous.toml b/internal/toml-test/tests/valid/array/hetergeneous.toml new file mode 100644 index 00000000..a246fcf1 --- /dev/null +++ b/internal/toml-test/tests/valid/array/hetergeneous.toml @@ -0,0 +1 @@ +mixed = [[1, 2], ["a", "b"], [1.1, 2.1]] diff --git a/internal/toml-test/tests/valid/array/mixed-int-array.json b/internal/toml-test/tests/valid/array/mixed-int-array.json new file mode 100644 index 00000000..2f3ac5ee --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-int-array.json @@ -0,0 +1,14 @@ +{ + "arrays-and-ints": [ + { + "type": "integer", + "value": "1" + }, + [ + { + "type": "string", + "value": "Arrays are not integers." + } + ] + ] +} diff --git a/internal/toml-test/tests/valid/array/mixed-int-array.toml b/internal/toml-test/tests/valid/array/mixed-int-array.toml new file mode 100644 index 00000000..051ec731 --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-int-array.toml @@ -0,0 +1 @@ +arrays-and-ints = [1, ["Arrays are not integers."]] diff --git a/internal/toml-test/tests/valid/array/mixed-int-float.json b/internal/toml-test/tests/valid/array/mixed-int-float.json new file mode 100644 index 00000000..e73059b8 --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-int-float.json @@ -0,0 +1,12 @@ +{ + "ints-and-floats": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "float", + "value": "1.1" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/mixed-int-float.toml b/internal/toml-test/tests/valid/array/mixed-int-float.toml new file mode 100644 index 00000000..a5aa9b7a --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-int-float.toml @@ -0,0 +1 @@ +ints-and-floats = [1, 1.1] diff --git a/internal/toml-test/tests/valid/array/mixed-int-string.json b/internal/toml-test/tests/valid/array/mixed-int-string.json new file mode 100644 index 00000000..c6acc763 --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-int-string.json @@ -0,0 +1,12 @@ +{ + "strings-and-ints": [ + { + "type": "string", + "value": "hi" + }, + { + "type": "integer", + "value": "42" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/mixed-int-string.toml b/internal/toml-test/tests/valid/array/mixed-int-string.toml new file mode 100644 index 00000000..f3483080 --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-int-string.toml @@ -0,0 +1 @@ +strings-and-ints = ["hi", 42] diff --git a/internal/toml-test/tests/valid/array/mixed-string-table.json b/internal/toml-test/tests/valid/array/mixed-string-table.json new file mode 100644 index 00000000..6185aa95 --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-string-table.json @@ -0,0 +1,22 @@ +{ + "contributors": [ + { + "type": "string", + "value": "Foo Bar \u003cfoo@example.com\u003e" + }, + { + "email": { + "type": "string", + "value": "bazqux@example.com" + }, + "name": { + "type": "string", + "value": "Baz Qux" + }, + "url": { + "type": "string", + "value": "https://example.com/bazqux" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/array/mixed-string-table.toml b/internal/toml-test/tests/valid/array/mixed-string-table.toml new file mode 100644 index 00000000..bd7ada8d --- /dev/null +++ b/internal/toml-test/tests/valid/array/mixed-string-table.toml @@ -0,0 +1,4 @@ +contributors = [ + "Foo Bar ", + { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } +] diff --git a/internal/toml-test/tests/valid/array/nested-double.json b/internal/toml-test/tests/valid/array/nested-double.json new file mode 100644 index 00000000..c89a8c9b --- /dev/null +++ b/internal/toml-test/tests/valid/array/nested-double.json @@ -0,0 +1,28 @@ +{ + "nest": [ + [ + [ + { + "type": "string", + "value": "a" + } + ], + [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + [ + { + "type": "integer", + "value": "3" + } + ] + ] + ] + ] +} diff --git a/internal/toml-test/tests/valid/array/nested-double.toml b/internal/toml-test/tests/valid/array/nested-double.toml new file mode 100644 index 00000000..c1de7477 --- /dev/null +++ b/internal/toml-test/tests/valid/array/nested-double.toml @@ -0,0 +1,6 @@ +nest = [ + [ + ["a"], + [1, 2, [3]] + ] +] diff --git a/internal/toml-test/tests/valid/array/nested-inline-table.json b/internal/toml-test/tests/valid/array/nested-inline-table.json new file mode 100644 index 00000000..2ae5fa70 --- /dev/null +++ b/internal/toml-test/tests/valid/array/nested-inline-table.json @@ -0,0 +1,7 @@ +{ + "a": [ + { + "b": {} + } + ] +} diff --git a/internal/toml-test/tests/valid/array/nested-inline-table.toml b/internal/toml-test/tests/valid/array/nested-inline-table.toml new file mode 100644 index 00000000..e1e24f6c --- /dev/null +++ b/internal/toml-test/tests/valid/array/nested-inline-table.toml @@ -0,0 +1 @@ +a = [ { b = {} } ] diff --git a/internal/toml-test/tests/valid/array/nested.json b/internal/toml-test/tests/valid/array/nested.json new file mode 100644 index 00000000..72c75897 --- /dev/null +++ b/internal/toml-test/tests/valid/array/nested.json @@ -0,0 +1,16 @@ +{ + "nest": [ + [ + { + "type": "string", + "value": "a" + } + ], + [ + { + "type": "string", + "value": "b" + } + ] + ] +} diff --git a/internal/toml-test/tests/valid/array/nested.toml b/internal/toml-test/tests/valid/array/nested.toml new file mode 100644 index 00000000..ce330224 --- /dev/null +++ b/internal/toml-test/tests/valid/array/nested.toml @@ -0,0 +1 @@ +nest = [["a"], ["b"]] diff --git a/internal/toml-test/tests/valid/array/nospaces.json b/internal/toml-test/tests/valid/array/nospaces.json new file mode 100644 index 00000000..6c89fced --- /dev/null +++ b/internal/toml-test/tests/valid/array/nospaces.json @@ -0,0 +1,16 @@ +{ + "ints": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + { + "type": "integer", + "value": "3" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/nospaces.toml b/internal/toml-test/tests/valid/array/nospaces.toml new file mode 100644 index 00000000..66189367 --- /dev/null +++ b/internal/toml-test/tests/valid/array/nospaces.toml @@ -0,0 +1 @@ +ints = [1,2,3] diff --git a/internal/toml-test/tests/valid/array/string-quote-comma-2.json b/internal/toml-test/tests/valid/array/string-quote-comma-2.json new file mode 100644 index 00000000..7cd54063 --- /dev/null +++ b/internal/toml-test/tests/valid/array/string-quote-comma-2.json @@ -0,0 +1,8 @@ +{ + "title": [ + { + "type": "string", + "value": " \", " + } + ] +} diff --git a/internal/toml-test/tests/valid/array/string-quote-comma-2.toml b/internal/toml-test/tests/valid/array/string-quote-comma-2.toml new file mode 100644 index 00000000..4758ddca --- /dev/null +++ b/internal/toml-test/tests/valid/array/string-quote-comma-2.toml @@ -0,0 +1 @@ +title = [ " \", ",] diff --git a/internal/toml-test/tests/valid/array/string-quote-comma.json b/internal/toml-test/tests/valid/array/string-quote-comma.json new file mode 100644 index 00000000..b78db423 --- /dev/null +++ b/internal/toml-test/tests/valid/array/string-quote-comma.json @@ -0,0 +1,12 @@ +{ + "title": [ + { + "type": "string", + "value": "Client: \"XXXX\", Job: XXXX" + }, + { + "type": "string", + "value": "Code: XXXX" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/string-quote-comma.toml b/internal/toml-test/tests/valid/array/string-quote-comma.toml new file mode 100644 index 00000000..6b458e1e --- /dev/null +++ b/internal/toml-test/tests/valid/array/string-quote-comma.toml @@ -0,0 +1,4 @@ +title = [ +"Client: \"XXXX\", Job: XXXX", +"Code: XXXX" +] diff --git a/internal/toml-test/tests/valid/array/string-with-comma.json b/internal/toml-test/tests/valid/array/string-with-comma.json new file mode 100644 index 00000000..42b77ef7 --- /dev/null +++ b/internal/toml-test/tests/valid/array/string-with-comma.json @@ -0,0 +1,12 @@ +{ + "title": [ + { + "type": "string", + "value": "Client: XXXX, Job: XXXX" + }, + { + "type": "string", + "value": "Code: XXXX" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/string-with-comma.toml b/internal/toml-test/tests/valid/array/string-with-comma.toml new file mode 100644 index 00000000..655c40e2 --- /dev/null +++ b/internal/toml-test/tests/valid/array/string-with-comma.toml @@ -0,0 +1,4 @@ +title = [ +"Client: XXXX, Job: XXXX", +"Code: XXXX" +] diff --git a/internal/toml-test/tests/valid/array/strings.json b/internal/toml-test/tests/valid/array/strings.json new file mode 100644 index 00000000..27617b4d --- /dev/null +++ b/internal/toml-test/tests/valid/array/strings.json @@ -0,0 +1,20 @@ +{ + "string_array": [ + { + "type": "string", + "value": "all" + }, + { + "type": "string", + "value": "strings" + }, + { + "type": "string", + "value": "are the same" + }, + { + "type": "string", + "value": "type" + } + ] +} diff --git a/internal/toml-test/tests/valid/array/strings.toml b/internal/toml-test/tests/valid/array/strings.toml new file mode 100644 index 00000000..51894ce1 --- /dev/null +++ b/internal/toml-test/tests/valid/array/strings.toml @@ -0,0 +1 @@ +string_array = [ "all", 'strings', """are the same""", '''type'''] diff --git a/internal/toml-test/tests/valid/array/table-array-string-backslash.json b/internal/toml-test/tests/valid/array/table-array-string-backslash.json new file mode 100644 index 00000000..2c0feb13 --- /dev/null +++ b/internal/toml-test/tests/valid/array/table-array-string-backslash.json @@ -0,0 +1,10 @@ +{ + "foo": [ + { + "bar": { + "type": "string", + "value": "\"{{baz}}\"" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/array/table-array-string-backslash.toml b/internal/toml-test/tests/valid/array/table-array-string-backslash.toml new file mode 100644 index 00000000..f0de81e0 --- /dev/null +++ b/internal/toml-test/tests/valid/array/table-array-string-backslash.toml @@ -0,0 +1 @@ +foo = [ { bar="\"{{baz}}\""} ] diff --git a/internal/toml-test/tests/valid/bool/bool.json b/internal/toml-test/tests/valid/bool/bool.json new file mode 100644 index 00000000..be47d6d0 --- /dev/null +++ b/internal/toml-test/tests/valid/bool/bool.json @@ -0,0 +1,10 @@ +{ + "f": { + "type": "bool", + "value": "false" + }, + "t": { + "type": "bool", + "value": "true" + } +} diff --git a/internal/toml-test/tests/valid/bool/bool.toml b/internal/toml-test/tests/valid/bool/bool.toml new file mode 100644 index 00000000..a8a829b3 --- /dev/null +++ b/internal/toml-test/tests/valid/bool/bool.toml @@ -0,0 +1,2 @@ +t = true +f = false diff --git a/internal/toml-test/tests/valid/comment/at-eof.json b/internal/toml-test/tests/valid/comment/at-eof.json new file mode 100644 index 00000000..af3154ab --- /dev/null +++ b/internal/toml-test/tests/valid/comment/at-eof.json @@ -0,0 +1,6 @@ +{ + "key": { + "type": "string", + "value": "value" + } +} diff --git a/internal/toml-test/tests/valid/comment/at-eof.toml b/internal/toml-test/tests/valid/comment/at-eof.toml new file mode 100644 index 00000000..090b4748 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/at-eof.toml @@ -0,0 +1,2 @@ +# This is a full-line comment +key = "value" # This is a comment at the end of a line diff --git a/internal/toml-test/tests/valid/comment/at-eof2.json b/internal/toml-test/tests/valid/comment/at-eof2.json new file mode 100644 index 00000000..af3154ab --- /dev/null +++ b/internal/toml-test/tests/valid/comment/at-eof2.json @@ -0,0 +1,6 @@ +{ + "key": { + "type": "string", + "value": "value" + } +} diff --git a/internal/toml-test/tests/valid/comment/at-eof2.toml b/internal/toml-test/tests/valid/comment/at-eof2.toml new file mode 100644 index 00000000..090b4748 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/at-eof2.toml @@ -0,0 +1,2 @@ +# This is a full-line comment +key = "value" # This is a comment at the end of a line diff --git a/internal/toml-test/tests/valid/comment/everywhere.json b/internal/toml-test/tests/valid/comment/everywhere.json new file mode 100644 index 00000000..c3dd422d --- /dev/null +++ b/internal/toml-test/tests/valid/comment/everywhere.json @@ -0,0 +1,22 @@ +{ + "group": { + "answer": { + "type": "integer", + "value": "42" + }, + "d": { + "type": "datetime", + "value": "1979-05-27T07:32:12-07:00" + }, + "more": [ + { + "type": "integer", + "value": "42" + }, + { + "type": "integer", + "value": "42" + } + ] + } +} diff --git a/internal/toml-test/tests/valid/comment/everywhere.toml b/internal/toml-test/tests/valid/comment/everywhere.toml new file mode 100644 index 00000000..aa9ebdc7 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/everywhere.toml @@ -0,0 +1,27 @@ +# Top comment. + # Top comment. +# Top comment. + +# [no-extraneous-groups-please] + +[group] # Comment +answer = 42 # Comment +# no-extraneous-keys-please = 999 +# Inbetween comment. +more = [ # Comment + # What about multiple # comments? + # Can you handle it? + # + # Evil. +# Evil. + 42, 42, # Comments within arrays are fun. + # What about multiple # comments? + # Can you handle it? + # + # Evil. +# Evil. +# ] Did I fool you? +] # Hopefully not. + +# Make sure the space between the datetime and "#" isn't lexed. +d = 1979-05-27T07:32:12-07:00 # c diff --git a/internal/toml-test/tests/valid/comment/tricky.json b/internal/toml-test/tests/valid/comment/tricky.json new file mode 100644 index 00000000..09948647 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/tricky.json @@ -0,0 +1,98 @@ +{ + "hash#tag": { + "#!": { + "type": "string", + "value": "hash bang" + }, + "arr3": [ + { + "type": "string", + "value": "#" + }, + { + "type": "string", + "value": "#" + }, + { + "type": "string", + "value": "###" + } + ], + "arr4": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + { + "type": "integer", + "value": "3" + }, + { + "type": "integer", + "value": "4" + } + ], + "arr5": [ + [ + [ + [ + [ + { + "type": "string", + "value": "#" + } + ] + ] + ] + ] + ], + "tbl1": { + "#": { + "type": "string", + "value": "}#" + } + } + }, + "section": { + "8": { + "type": "string", + "value": "eight" + }, + "eleven": { + "type": "float", + "value": "11.1" + }, + "five": { + "type": "float", + "value": "5.5" + }, + "four": { + "type": "string", + "value": "# no comment\n# nor this\n#also not comment" + }, + "one": { + "type": "string", + "value": "11" + }, + "six": { + "type": "integer", + "value": "6" + }, + "ten": { + "type": "float", + "value": "1000.0" + }, + "three": { + "type": "string", + "value": "#" + }, + "two": { + "type": "string", + "value": "22#" + } + } +} diff --git a/internal/toml-test/tests/valid/comment/tricky.toml b/internal/toml-test/tests/valid/comment/tricky.toml new file mode 100644 index 00000000..c95f94d0 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/tricky.toml @@ -0,0 +1,31 @@ +[section]#attached comment +#[notsection] +one = "11"#cmt +two = "22#" +three = '#' + +four = """# no comment +# nor this +#also not comment"""#is_comment + +five = 5.5#66 +six = 6#7 +8 = "eight" +#nine = 99 +ten = 10e2#1 +eleven = 1.11e1#23 + +["hash#tag"] +"#!" = "hash bang" +arr3 = [ "#", '#', """###""" ] +arr4 = [ 1,# 9, 9, +2#,9 +,#9 +3#] +,4] +arr5 = [[[[#["#"], +["#"]]]]#] +] +tbl1 = { "#" = '}#'}#}} + + diff --git a/internal/toml-test/tests/valid/datetime/datetime.json b/internal/toml-test/tests/valid/datetime/datetime.json new file mode 100644 index 00000000..51463359 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/datetime.json @@ -0,0 +1,10 @@ +{ + "lower": { + "type": "datetime", + "value": "1987-07-05T17:45:00Z" + }, + "space": { + "type": "datetime", + "value": "1987-07-05T17:45:00Z" + } +} diff --git a/internal/toml-test/tests/valid/datetime/datetime.toml b/internal/toml-test/tests/valid/datetime/datetime.toml new file mode 100644 index 00000000..653d521f --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/datetime.toml @@ -0,0 +1,2 @@ +space = 1987-07-05 17:45:00Z +lower = 1987-07-05t17:45:00z diff --git a/internal/toml-test/tests/valid/datetime/local-date.json b/internal/toml-test/tests/valid/datetime/local-date.json new file mode 100644 index 00000000..8fea2fe0 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/local-date.json @@ -0,0 +1,6 @@ +{ + "bestdayever": { + "type": "date-local", + "value": "1987-07-05" + } +} diff --git a/internal/toml-test/tests/valid/datetime/local-date.toml b/internal/toml-test/tests/valid/datetime/local-date.toml new file mode 100644 index 00000000..1be4a5f8 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/local-date.toml @@ -0,0 +1 @@ +bestdayever = 1987-07-05 diff --git a/internal/toml-test/tests/valid/datetime/local-time.json b/internal/toml-test/tests/valid/datetime/local-time.json new file mode 100644 index 00000000..5e527e97 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/local-time.json @@ -0,0 +1,10 @@ +{ + "besttimeever": { + "type": "time-local", + "value": "17:45:00" + }, + "milliseconds": { + "type": "time-local", + "value": "10:32:00.555" + } +} diff --git a/internal/toml-test/tests/valid/datetime/local-time.toml b/internal/toml-test/tests/valid/datetime/local-time.toml new file mode 100644 index 00000000..6b07f6ff --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/local-time.toml @@ -0,0 +1,2 @@ +besttimeever = 17:45:00 +milliseconds = 10:32:00.555 diff --git a/internal/toml-test/tests/valid/datetime/local.json b/internal/toml-test/tests/valid/datetime/local.json new file mode 100644 index 00000000..12f8df5d --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/local.json @@ -0,0 +1,14 @@ +{ + "local": { + "type": "datetime-local", + "value": "1987-07-05T17:45:00" + }, + "milli": { + "type": "datetime-local", + "value": "1977-12-21T10:32:00.555" + }, + "space": { + "type": "datetime-local", + "value": "1987-07-05T17:45:00" + } +} diff --git a/internal/toml-test/tests/valid/datetime/local.toml b/internal/toml-test/tests/valid/datetime/local.toml new file mode 100644 index 00000000..ab425eca --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/local.toml @@ -0,0 +1,3 @@ +local = 1987-07-05T17:45:00 +milli = 1977-12-21T10:32:00.555 +space = 1987-07-05 17:45:00 diff --git a/internal/toml-test/tests/valid/datetime/milliseconds.json b/internal/toml-test/tests/valid/datetime/milliseconds.json new file mode 100644 index 00000000..bb896af4 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/milliseconds.json @@ -0,0 +1,18 @@ +{ + "utc1": { + "type": "datetime", + "value": "1987-07-05T17:45:56.123456Z" + }, + "utc2": { + "type": "datetime", + "value": "1987-07-05T17:45:56.600000Z" + }, + "wita1": { + "type": "datetime", + "value": "1987-07-05T17:45:56.123456+08:00" + }, + "wita2": { + "type": "datetime", + "value": "1987-07-05T17:45:56.600000+08:00" + } +} diff --git a/internal/toml-test/tests/valid/datetime/milliseconds.toml b/internal/toml-test/tests/valid/datetime/milliseconds.toml new file mode 100644 index 00000000..a6c05903 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/milliseconds.toml @@ -0,0 +1,4 @@ +utc1 = 1987-07-05T17:45:56.123456Z +utc2 = 1987-07-05T17:45:56.6Z +wita1 = 1987-07-05T17:45:56.123456+08:00 +wita2 = 1987-07-05T17:45:56.6+08:00 diff --git a/internal/toml-test/tests/valid/datetime/timezone.json b/internal/toml-test/tests/valid/datetime/timezone.json new file mode 100644 index 00000000..8dc83281 --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/timezone.json @@ -0,0 +1,18 @@ +{ + "nzdt": { + "type": "datetime", + "value": "1987-07-05T17:45:56+13:00" + }, + "nzst": { + "type": "datetime", + "value": "1987-07-05T17:45:56+12:00" + }, + "pdt": { + "type": "datetime", + "value": "1987-07-05T17:45:56-05:00" + }, + "utc": { + "type": "datetime", + "value": "1987-07-05T17:45:56Z" + } +} diff --git a/internal/toml-test/tests/valid/datetime/timezone.toml b/internal/toml-test/tests/valid/datetime/timezone.toml new file mode 100644 index 00000000..20f3835b --- /dev/null +++ b/internal/toml-test/tests/valid/datetime/timezone.toml @@ -0,0 +1,4 @@ +utc = 1987-07-05T17:45:56Z +pdt = 1987-07-05T17:45:56-05:00 +nzst = 1987-07-05T17:45:56+12:00 +nzdt = 1987-07-05T17:45:56+13:00 # DST diff --git a/internal/toml-test/tests/valid/empty-file.json b/internal/toml-test/tests/valid/empty-file.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/internal/toml-test/tests/valid/empty-file.json @@ -0,0 +1 @@ +{} diff --git a/internal/toml-test/tests/valid/empty-file.toml b/internal/toml-test/tests/valid/empty-file.toml new file mode 100644 index 00000000..e69de29b diff --git a/internal/toml-test/tests/valid/example.json b/internal/toml-test/tests/valid/example.json new file mode 100644 index 00000000..2ea95a20 --- /dev/null +++ b/internal/toml-test/tests/valid/example.json @@ -0,0 +1,26 @@ +{ + "best-day-ever": { + "type": "datetime", + "value": "1987-07-05T17:45:00Z" + }, + "numtheory": { + "boring": { + "type": "bool", + "value": "false" + }, + "perfection": [ + { + "type": "integer", + "value": "6" + }, + { + "type": "integer", + "value": "28" + }, + { + "type": "integer", + "value": "496" + } + ] + } +} diff --git a/internal/toml-test/tests/valid/example.toml b/internal/toml-test/tests/valid/example.toml new file mode 100644 index 00000000..8cb02e01 --- /dev/null +++ b/internal/toml-test/tests/valid/example.toml @@ -0,0 +1,5 @@ +best-day-ever = 1987-07-05T17:45:00Z + +[numtheory] +boring = false +perfection = [6, 28, 496] diff --git a/internal/toml-test/tests/valid/float/exponent.json b/internal/toml-test/tests/valid/float/exponent.json new file mode 100644 index 00000000..e79a6e13 --- /dev/null +++ b/internal/toml-test/tests/valid/float/exponent.json @@ -0,0 +1,34 @@ +{ + "lower": { + "type": "float", + "value": "300.0" + }, + "minustenth": { + "type": "float", + "value": "-0.1" + }, + "neg": { + "type": "float", + "value": "0.03" + }, + "pointlower": { + "type": "float", + "value": "310.0" + }, + "pointupper": { + "type": "float", + "value": "310.0" + }, + "pos": { + "type": "float", + "value": "300.0" + }, + "upper": { + "type": "float", + "value": "300.0" + }, + "zero": { + "type": "float", + "value": "3.0" + } +} diff --git a/internal/toml-test/tests/valid/float/exponent.toml b/internal/toml-test/tests/valid/float/exponent.toml new file mode 100644 index 00000000..573e0a85 --- /dev/null +++ b/internal/toml-test/tests/valid/float/exponent.toml @@ -0,0 +1,8 @@ +lower = 3e2 +upper = 3E2 +neg = 3e-2 +pos = 3E+2 +zero = 3e0 +pointlower = 3.1e2 +pointupper = 3.1E2 +minustenth = -1E-1 diff --git a/internal/toml-test/tests/valid/float/float.json b/internal/toml-test/tests/valid/float/float.json new file mode 100644 index 00000000..f92d8d87 --- /dev/null +++ b/internal/toml-test/tests/valid/float/float.json @@ -0,0 +1,18 @@ +{ + "negpi": { + "type": "float", + "value": "-3.14" + }, + "pi": { + "type": "float", + "value": "3.14" + }, + "pospi": { + "type": "float", + "value": "3.14" + }, + "zero-intpart": { + "type": "float", + "value": "0.123" + } +} diff --git a/internal/toml-test/tests/valid/float/float.toml b/internal/toml-test/tests/valid/float/float.toml new file mode 100644 index 00000000..5f023229 --- /dev/null +++ b/internal/toml-test/tests/valid/float/float.toml @@ -0,0 +1,4 @@ +pi = 3.14 +pospi = +3.14 +negpi = -3.14 +zero-intpart = 0.123 diff --git a/internal/toml-test/tests/valid/float/inf-and-nan.json b/internal/toml-test/tests/valid/float/inf-and-nan.json new file mode 100644 index 00000000..e3f1ba3c --- /dev/null +++ b/internal/toml-test/tests/valid/float/inf-and-nan.json @@ -0,0 +1,26 @@ +{ + "infinity": { + "type": "float", + "value": "inf" + }, + "infinity_neg": { + "type": "float", + "value": "-inf" + }, + "infinity_plus": { + "type": "float", + "value": "+inf" + }, + "nan": { + "type": "float", + "value": "nan" + }, + "nan_neg": { + "type": "float", + "value": "nan" + }, + "nan_plus": { + "type": "float", + "value": "nan" + } +} diff --git a/internal/toml-test/tests/valid/float/inf-and-nan.toml b/internal/toml-test/tests/valid/float/inf-and-nan.toml new file mode 100644 index 00000000..c8f8459c --- /dev/null +++ b/internal/toml-test/tests/valid/float/inf-and-nan.toml @@ -0,0 +1,8 @@ +# We don't encode +nan and -nan back with the signs; many languages don't +# support a sign on NaN (it doesn't really make much sense). +nan = nan +nan_neg = -nan +nan_plus = +nan +infinity = inf +infinity_neg = -inf +infinity_plus = +inf diff --git a/internal/toml-test/tests/valid/float/long.json b/internal/toml-test/tests/valid/float/long.json new file mode 100644 index 00000000..73d75052 --- /dev/null +++ b/internal/toml-test/tests/valid/float/long.json @@ -0,0 +1,10 @@ +{ + "longpi": { + "type": "float", + "value": "3.141592653589793" + }, + "neglongpi": { + "type": "float", + "value": "-3.141592653589793" + } +} diff --git a/internal/toml-test/tests/valid/float/long.toml b/internal/toml-test/tests/valid/float/long.toml new file mode 100644 index 00000000..9558ae47 --- /dev/null +++ b/internal/toml-test/tests/valid/float/long.toml @@ -0,0 +1,2 @@ +longpi = 3.141592653589793 +neglongpi = -3.141592653589793 diff --git a/internal/toml-test/tests/valid/float/underscore.json b/internal/toml-test/tests/valid/float/underscore.json new file mode 100644 index 00000000..f54f7b50 --- /dev/null +++ b/internal/toml-test/tests/valid/float/underscore.json @@ -0,0 +1,14 @@ +{ + "after": { + "type": "float", + "value": "3141.5927" + }, + "before": { + "type": "float", + "value": "3141.5927" + }, + "exponent": { + "type": "float", + "value": "3.0e14" + } +} diff --git a/internal/toml-test/tests/valid/float/underscore.toml b/internal/toml-test/tests/valid/float/underscore.toml new file mode 100644 index 00000000..343353a8 --- /dev/null +++ b/internal/toml-test/tests/valid/float/underscore.toml @@ -0,0 +1,3 @@ +before = 3_141.5927 +after = 3141.592_7 +exponent = 3e1_4 diff --git a/internal/toml-test/tests/valid/float/zero.json b/internal/toml-test/tests/valid/float/zero.json new file mode 100644 index 00000000..43381dd9 --- /dev/null +++ b/internal/toml-test/tests/valid/float/zero.json @@ -0,0 +1,30 @@ +{ + "f1": { + "type": "float", + "value": "0" + }, + "f2": { + "type": "float", + "value": "0" + }, + "f3": { + "type": "float", + "value": "0" + }, + "f4": { + "type": "float", + "value": "0" + }, + "f5": { + "type": "float", + "value": "0" + }, + "f6": { + "type": "float", + "value": "0" + }, + "f7": { + "type": "float", + "value": "0" + } +} diff --git a/internal/toml-test/tests/valid/float/zero.toml b/internal/toml-test/tests/valid/float/zero.toml new file mode 100644 index 00000000..5f2a8ffa --- /dev/null +++ b/internal/toml-test/tests/valid/float/zero.toml @@ -0,0 +1,7 @@ +f1 = 0.0 +f2 = +0.0 +f3 = -0.0 +f4 = 0e0 +f5 = 0e00 +f6 = +0e0 +f7 = -0e0 diff --git a/internal/toml-test/tests/valid/implicit-and-explicit-after.json b/internal/toml-test/tests/valid/implicit-and-explicit-after.json new file mode 100644 index 00000000..663a34e8 --- /dev/null +++ b/internal/toml-test/tests/valid/implicit-and-explicit-after.json @@ -0,0 +1,16 @@ +{ + "a": { + "b": { + "c": { + "answer": { + "type": "integer", + "value": "42" + } + } + }, + "better": { + "type": "integer", + "value": "43" + } + } +} diff --git a/internal/toml-test/tests/valid/implicit-and-explicit-after.toml b/internal/toml-test/tests/valid/implicit-and-explicit-after.toml new file mode 100644 index 00000000..c0e8865b --- /dev/null +++ b/internal/toml-test/tests/valid/implicit-and-explicit-after.toml @@ -0,0 +1,5 @@ +[a.b.c] +answer = 42 + +[a] +better = 43 diff --git a/internal/toml-test/tests/valid/implicit-and-explicit-before.json b/internal/toml-test/tests/valid/implicit-and-explicit-before.json new file mode 100644 index 00000000..663a34e8 --- /dev/null +++ b/internal/toml-test/tests/valid/implicit-and-explicit-before.json @@ -0,0 +1,16 @@ +{ + "a": { + "b": { + "c": { + "answer": { + "type": "integer", + "value": "42" + } + } + }, + "better": { + "type": "integer", + "value": "43" + } + } +} diff --git a/internal/toml-test/tests/valid/implicit-and-explicit-before.toml b/internal/toml-test/tests/valid/implicit-and-explicit-before.toml new file mode 100644 index 00000000..eee68ff5 --- /dev/null +++ b/internal/toml-test/tests/valid/implicit-and-explicit-before.toml @@ -0,0 +1,5 @@ +[a] +better = 43 + +[a.b.c] +answer = 42 diff --git a/internal/toml-test/tests/valid/implicit-groups.json b/internal/toml-test/tests/valid/implicit-groups.json new file mode 100644 index 00000000..347c693c --- /dev/null +++ b/internal/toml-test/tests/valid/implicit-groups.json @@ -0,0 +1,12 @@ +{ + "a": { + "b": { + "c": { + "answer": { + "type": "integer", + "value": "42" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/implicit-groups.toml b/internal/toml-test/tests/valid/implicit-groups.toml new file mode 100644 index 00000000..b6333e49 --- /dev/null +++ b/internal/toml-test/tests/valid/implicit-groups.toml @@ -0,0 +1,2 @@ +[a.b.c] +answer = 42 diff --git a/internal/toml-test/tests/valid/inline-table/array.json b/internal/toml-test/tests/valid/inline-table/array.json new file mode 100644 index 00000000..fe78bf6b --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/array.json @@ -0,0 +1,34 @@ +{ + "people": [ + { + "first_name": { + "type": "string", + "value": "Bruce" + }, + "last_name": { + "type": "string", + "value": "Springsteen" + } + }, + { + "first_name": { + "type": "string", + "value": "Eric" + }, + "last_name": { + "type": "string", + "value": "Clapton" + } + }, + { + "first_name": { + "type": "string", + "value": "Bob" + }, + "last_name": { + "type": "string", + "value": "Seger" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/inline-table/array.toml b/internal/toml-test/tests/valid/inline-table/array.toml new file mode 100644 index 00000000..3fa60d66 --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/array.toml @@ -0,0 +1,3 @@ +people = [{first_name = "Bruce", last_name = "Springsteen"}, + {first_name = "Eric", last_name = "Clapton"}, + {first_name = "Bob", last_name = "Seger"}] diff --git a/internal/toml-test/tests/valid/inline-table/bool.json b/internal/toml-test/tests/valid/inline-table/bool.json new file mode 100644 index 00000000..717952fa --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/bool.json @@ -0,0 +1,12 @@ +{ + "a": { + "a": { + "type": "bool", + "value": "true" + }, + "b": { + "type": "bool", + "value": "false" + } + } +} diff --git a/internal/toml-test/tests/valid/inline-table/bool.toml b/internal/toml-test/tests/valid/inline-table/bool.toml new file mode 100644 index 00000000..d228fc26 --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/bool.toml @@ -0,0 +1 @@ +a = {a = true, b = false} diff --git a/internal/toml-test/tests/valid/inline-table/empty.json b/internal/toml-test/tests/valid/inline-table/empty.json new file mode 100644 index 00000000..28beacf8 --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/empty.json @@ -0,0 +1,30 @@ +{ + "empty1": {}, + "empty2": {}, + "empty_in_array": [ + { + "not_empty": { + "type": "integer", + "value": "1" + } + }, + {} + ], + "empty_in_array2": [ + {}, + { + "not_empty": { + "type": "integer", + "value": "1" + } + } + ], + "many_empty": [ + {}, + {}, + {} + ], + "nested_empty": { + "empty": {} + } +} diff --git a/internal/toml-test/tests/valid/inline-table/empty.toml b/internal/toml-test/tests/valid/inline-table/empty.toml new file mode 100644 index 00000000..910d458f --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/empty.toml @@ -0,0 +1,6 @@ +empty1 = {} +empty2 = { } +empty_in_array = [ { not_empty = 1 }, {} ] +empty_in_array2 = [{},{not_empty=1}] +many_empty = [{},{},{}] +nested_empty = {"empty"={}} diff --git a/internal/toml-test/tests/valid/inline-table/end-in-bool.json b/internal/toml-test/tests/valid/inline-table/end-in-bool.json new file mode 100644 index 00000000..90e700ab --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/end-in-bool.json @@ -0,0 +1,16 @@ +{ + "black": { + "allow_prereleases": { + "type": "bool", + "value": "true" + }, + "python": { + "type": "string", + "value": "\u003e3.6" + }, + "version": { + "type": "string", + "value": "\u003e=18.9b0" + } + } +} diff --git a/internal/toml-test/tests/valid/inline-table/end-in-bool.toml b/internal/toml-test/tests/valid/inline-table/end-in-bool.toml new file mode 100644 index 00000000..94e5651d --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/end-in-bool.toml @@ -0,0 +1 @@ +black = { python=">3.6", version=">=18.9b0", allow_prereleases=true } diff --git a/internal/toml-test/tests/valid/inline-table/inline-table.json b/internal/toml-test/tests/valid/inline-table/inline-table.json new file mode 100644 index 00000000..2468f62c --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/inline-table.json @@ -0,0 +1,48 @@ +{ + "name": { + "first": { + "type": "string", + "value": "Tom" + }, + "last": { + "type": "string", + "value": "Preston-Werner" + } + }, + "point": { + "x": { + "type": "integer", + "value": "1" + }, + "y": { + "type": "integer", + "value": "2" + } + }, + "simple": { + "a": { + "type": "integer", + "value": "1" + } + }, + "str-key": { + "a": { + "type": "integer", + "value": "1" + } + }, + "table-array": [ + { + "a": { + "type": "integer", + "value": "1" + } + }, + { + "b": { + "type": "integer", + "value": "2" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/inline-table/inline-table.toml b/internal/toml-test/tests/valid/inline-table/inline-table.toml new file mode 100644 index 00000000..257047ee --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/inline-table.toml @@ -0,0 +1,5 @@ +name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } +simple = { a = 1 } +str-key = { "a" = 1 } +table-array = [{ "a" = 1 }, { "b" = 2 }] diff --git a/internal/toml-test/tests/valid/inline-table/key-dotted.json b/internal/toml-test/tests/valid/inline-table/key-dotted.json new file mode 100644 index 00000000..38868032 --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/key-dotted.json @@ -0,0 +1,140 @@ +{ + "a": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + }, + "arr": [ + { + "T": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + }, + "t": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + } + }, + { + "T": { + "a": { + "b": { + "type": "integer", + "value": "2" + } + } + }, + "t": { + "a": { + "b": { + "type": "integer", + "value": "2" + } + } + } + } + ], + "b": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + }, + "c": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + }, + "d": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + }, + "e": { + "a": { + "b": { + "type": "integer", + "value": "1" + } + } + }, + "inline": { + "a": { + "b": { + "type": "integer", + "value": "42" + } + } + }, + "many": { + "dots": { + "here": { + "dot": { + "dot": { + "dot": { + "a": { + "b": { + "c": { + "type": "integer", + "value": "1" + }, + "d": { + "type": "integer", + "value": "2" + } + } + } + } + } + } + } + } + }, + "tbl": { + "a": { + "b": { + "c": { + "d": { + "e": { + "type": "integer", + "value": "1" + } + } + } + } + }, + "x": { + "a": { + "b": { + "c": { + "d": { + "e": { + "type": "integer", + "value": "1" + } + } + } + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/inline-table/key-dotted.toml b/internal/toml-test/tests/valid/inline-table/key-dotted.toml new file mode 100644 index 00000000..e812943a --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/key-dotted.toml @@ -0,0 +1,23 @@ +inline = {a.b = 42} + +many.dots.here.dot.dot.dot = {a.b.c = 1, a.b.d = 2} + +a = { a.b = 1 } +b = { "a"."b" = 1 } +c = { a . b = 1 } +d = { 'a' . "b" = 1 } +e = {a.b=1} + +[tbl] +a.b.c = {d.e=1} + +[tbl.x] +a.b.c = {d.e=1} + +[[arr]] +t = {a.b=1} +T = {a.b=1} + +[[arr]] +t = {a.b=2} +T = {a.b=2} diff --git a/internal/toml-test/tests/valid/inline-table/multiline.json b/internal/toml-test/tests/valid/inline-table/multiline.json new file mode 100644 index 00000000..f946d819 --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/multiline.json @@ -0,0 +1,20 @@ +{ + "tbl_multiline": { + "a": { + "type": "integer", + "value": "1" + }, + "b": { + "type": "string", + "value": "multiline\n" + }, + "c": { + "type": "string", + "value": "and yet\nanother line" + }, + "d": { + "type": "integer", + "value": "4" + } + } +} diff --git a/internal/toml-test/tests/valid/inline-table/multiline.toml b/internal/toml-test/tests/valid/inline-table/multiline.toml new file mode 100644 index 00000000..a653b18f --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/multiline.toml @@ -0,0 +1,4 @@ +tbl_multiline = { a = 1, b = """ +multiline +""", c = """and yet +another line""", d = 4 } diff --git a/internal/toml-test/tests/valid/inline-table/nest.json b/internal/toml-test/tests/valid/inline-table/nest.json new file mode 100644 index 00000000..70aebb3f --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/nest.json @@ -0,0 +1,64 @@ +{ + "arr_arr_tbl_empty": [ + [ + {} + ] + ], + "arr_arr_tbl_val": [ + [ + { + "one": { + "type": "integer", + "value": "1" + } + } + ] + ], + "arr_arr_tbls": [ + [ + { + "one": { + "type": "integer", + "value": "1" + } + }, + { + "two": { + "type": "integer", + "value": "2" + } + } + ] + ], + "arr_tbl_tbl": [ + { + "tbl": { + "one": { + "type": "integer", + "value": "1" + } + } + } + ], + "tbl_arr_tbl": { + "arr_tbl": [ + { + "one": { + "type": "integer", + "value": "1" + } + } + ] + }, + "tbl_tbl_empty": { + "tbl_0": {} + }, + "tbl_tbl_val": { + "tbl_1": { + "one": { + "type": "integer", + "value": "1" + } + } + } +} diff --git a/internal/toml-test/tests/valid/inline-table/nest.toml b/internal/toml-test/tests/valid/inline-table/nest.toml new file mode 100644 index 00000000..2624c1d5 --- /dev/null +++ b/internal/toml-test/tests/valid/inline-table/nest.toml @@ -0,0 +1,10 @@ +tbl_tbl_empty = { tbl_0 = {} } +tbl_tbl_val = { tbl_1 = { one = 1 } } +tbl_arr_tbl = { arr_tbl = [ { one = 1 } ] } +arr_tbl_tbl = [ { tbl = { one = 1 } } ] + +# Array-of-array-of-table is interesting because it can only +# be represented in inline form. +arr_arr_tbl_empty = [ [ {} ] ] +arr_arr_tbl_val = [ [ { one = 1 } ] ] +arr_arr_tbls = [ [ { one = 1 }, { two = 2 } ] ] diff --git a/internal/toml-test/tests/valid/integer/integer.json b/internal/toml-test/tests/valid/integer/integer.json new file mode 100644 index 00000000..eee97580 --- /dev/null +++ b/internal/toml-test/tests/valid/integer/integer.json @@ -0,0 +1,18 @@ +{ + "answer": { + "type": "integer", + "value": "42" + }, + "neganswer": { + "type": "integer", + "value": "-42" + }, + "posanswer": { + "type": "integer", + "value": "42" + }, + "zero": { + "type": "integer", + "value": "0" + } +} diff --git a/internal/toml-test/tests/valid/integer/integer.toml b/internal/toml-test/tests/valid/integer/integer.toml new file mode 100644 index 00000000..b62de30a --- /dev/null +++ b/internal/toml-test/tests/valid/integer/integer.toml @@ -0,0 +1,4 @@ +answer = 42 +posanswer = +42 +neganswer = -42 +zero = 0 diff --git a/internal/toml-test/tests/valid/integer/literals.json b/internal/toml-test/tests/valid/integer/literals.json new file mode 100644 index 00000000..1a8555bd --- /dev/null +++ b/internal/toml-test/tests/valid/integer/literals.json @@ -0,0 +1,38 @@ +{ + "bin1": { + "type": "integer", + "value": "214" + }, + "bin2": { + "type": "integer", + "value": "5" + }, + "hex1": { + "type": "integer", + "value": "3735928559" + }, + "hex2": { + "type": "integer", + "value": "3735928559" + }, + "hex3": { + "type": "integer", + "value": "3735928559" + }, + "hex4": { + "type": "integer", + "value": "2439" + }, + "oct1": { + "type": "integer", + "value": "342391" + }, + "oct2": { + "type": "integer", + "value": "493" + }, + "oct3": { + "type": "integer", + "value": "501" + } +} diff --git a/internal/toml-test/tests/valid/integer/literals.toml b/internal/toml-test/tests/valid/integer/literals.toml new file mode 100644 index 00000000..a0785904 --- /dev/null +++ b/internal/toml-test/tests/valid/integer/literals.toml @@ -0,0 +1,11 @@ +bin1 = 0b11010110 +bin2 = 0b1_0_1 + +oct1 = 0o01234567 +oct2 = 0o755 +oct3 = 0o7_6_5 + +hex1 = 0xDEADBEEF +hex2 = 0xdeadbeef +hex3 = 0xdead_beef +hex4 = 0x00987 diff --git a/internal/toml-test/tests/valid/integer/long.json b/internal/toml-test/tests/valid/integer/long.json new file mode 100644 index 00000000..6f4f0a7c --- /dev/null +++ b/internal/toml-test/tests/valid/integer/long.json @@ -0,0 +1,10 @@ +{ + "int64-max": { + "type": "integer", + "value": "9223372036854775807" + }, + "int64-max-neg": { + "type": "integer", + "value": "-9223372036854775808" + } +} diff --git a/internal/toml-test/tests/valid/integer/long.toml b/internal/toml-test/tests/valid/integer/long.toml new file mode 100644 index 00000000..5db5ed79 --- /dev/null +++ b/internal/toml-test/tests/valid/integer/long.toml @@ -0,0 +1,2 @@ +int64-max = 9223372036854775807 +int64-max-neg = -9223372036854775808 diff --git a/internal/toml-test/tests/valid/integer/underscore.json b/internal/toml-test/tests/valid/integer/underscore.json new file mode 100644 index 00000000..10b9b591 --- /dev/null +++ b/internal/toml-test/tests/valid/integer/underscore.json @@ -0,0 +1,10 @@ +{ + "kilo": { + "type": "integer", + "value": "1000" + }, + "x": { + "type": "integer", + "value": "1111" + } +} diff --git a/internal/toml-test/tests/valid/integer/underscore.toml b/internal/toml-test/tests/valid/integer/underscore.toml new file mode 100644 index 00000000..7c2da5fe --- /dev/null +++ b/internal/toml-test/tests/valid/integer/underscore.toml @@ -0,0 +1,2 @@ +kilo = 1_000 +x = 1_1_1_1 diff --git a/internal/toml-test/tests/valid/integer/zero.json b/internal/toml-test/tests/valid/integer/zero.json new file mode 100644 index 00000000..9d5c7077 --- /dev/null +++ b/internal/toml-test/tests/valid/integer/zero.json @@ -0,0 +1,50 @@ +{ + "a2": { + "type": "integer", + "value": "0" + }, + "a3": { + "type": "integer", + "value": "0" + }, + "b1": { + "type": "integer", + "value": "0" + }, + "b2": { + "type": "integer", + "value": "0" + }, + "b3": { + "type": "integer", + "value": "0" + }, + "d1": { + "type": "integer", + "value": "0" + }, + "d2": { + "type": "integer", + "value": "0" + }, + "d3": { + "type": "integer", + "value": "0" + }, + "h1": { + "type": "integer", + "value": "0" + }, + "h2": { + "type": "integer", + "value": "0" + }, + "h3": { + "type": "integer", + "value": "0" + }, + "o1": { + "type": "integer", + "value": "0" + } +} diff --git a/internal/toml-test/tests/valid/integer/zero.toml b/internal/toml-test/tests/valid/integer/zero.toml new file mode 100644 index 00000000..4687c281 --- /dev/null +++ b/internal/toml-test/tests/valid/integer/zero.toml @@ -0,0 +1,15 @@ +d1 = 0 +d2 = +0 +d3 = -0 + +h1 = 0x0 +h2 = 0x00 +h3 = 0x00000 + +o1 = 0o0 +a2 = 0o00 +a3 = 0o00000 + +b1 = 0b0 +b2 = 0b00 +b3 = 0b00000 diff --git a/internal/toml-test/tests/valid/key/alphanum.json b/internal/toml-test/tests/valid/key/alphanum.json new file mode 100644 index 00000000..a54e1d35 --- /dev/null +++ b/internal/toml-test/tests/valid/key/alphanum.json @@ -0,0 +1,46 @@ +{ + "000111": { + "type": "string", + "value": "leading" + }, + "10e3": { + "type": "string", + "value": "false float" + }, + "123": { + "type": "string", + "value": "num" + }, + "2018_10": { + "001": { + "type": "integer", + "value": "1" + } + }, + "34-11": { + "type": "integer", + "value": "23" + }, + "a-a-a": { + "_": { + "type": "bool", + "value": "false" + } + }, + "alpha": { + "type": "string", + "value": "a" + }, + "one1two2": { + "type": "string", + "value": "mixed" + }, + "under_score": { + "type": "string", + "value": "___" + }, + "with-dash": { + "type": "string", + "value": "dashed" + } +} diff --git a/internal/toml-test/tests/valid/key/alphanum.toml b/internal/toml-test/tests/valid/key/alphanum.toml new file mode 100644 index 00000000..0632e9cc --- /dev/null +++ b/internal/toml-test/tests/valid/key/alphanum.toml @@ -0,0 +1,14 @@ +alpha = "a" +123 = "num" +000111 = "leading" +10e3 = "false float" +one1two2 = "mixed" +with-dash = "dashed" +under_score = "___" +34-11 = 23 + +[2018_10] +001 = 1 + +[a-a-a] +_ = false diff --git a/internal/toml-test/tests/valid/key/case-sensitive.json b/internal/toml-test/tests/valid/key/case-sensitive.json new file mode 100644 index 00000000..1f205d20 --- /dev/null +++ b/internal/toml-test/tests/valid/key/case-sensitive.json @@ -0,0 +1,38 @@ +{ + "Section": { + "M": { + "type": "string", + "value": "latin letter M" + }, + "name": { + "type": "string", + "value": "different section!!" + }, + "Îœ": { + "type": "string", + "value": "greek capital letter MU" + }, + "μ": { + "type": "string", + "value": "greek small letter mu" + } + }, + "sectioN": { + "type": "string", + "value": "NN" + }, + "section": { + "NAME": { + "type": "string", + "value": "upper" + }, + "Name": { + "type": "string", + "value": "capitalized" + }, + "name": { + "type": "string", + "value": "lower" + } + } +} diff --git a/internal/toml-test/tests/valid/key/case-sensitive.toml b/internal/toml-test/tests/valid/key/case-sensitive.toml new file mode 100644 index 00000000..e02b3a51 --- /dev/null +++ b/internal/toml-test/tests/valid/key/case-sensitive.toml @@ -0,0 +1,13 @@ +sectioN = "NN" + +[section] +name = "lower" +NAME = "upper" +Name = "capitalized" + +[Section] +name = "different section!!" +"μ" = "greek small letter mu" +"Îœ" = "greek capital letter MU" +M = "latin letter M" + diff --git a/internal/toml-test/tests/valid/key/dotted.json b/internal/toml-test/tests/valid/key/dotted.json new file mode 100644 index 00000000..a527a72c --- /dev/null +++ b/internal/toml-test/tests/valid/key/dotted.json @@ -0,0 +1,132 @@ +{ + "a": { + "few": { + "dots": { + "polka": { + "dance-with": { + "type": "string", + "value": "Dot" + }, + "dot": { + "type": "string", + "value": "again?" + } + } + } + } + }, + "arr": [ + { + "a": { + "b": { + "c": { + "type": "integer", + "value": "1" + }, + "d": { + "type": "integer", + "value": "2" + } + } + } + }, + { + "a": { + "b": { + "c": { + "type": "integer", + "value": "3" + }, + "d": { + "type": "integer", + "value": "4" + } + } + } + } + ], + "count": { + "a": { + "type": "integer", + "value": "1" + }, + "b": { + "type": "integer", + "value": "2" + }, + "c": { + "type": "integer", + "value": "3" + }, + "d": { + "type": "integer", + "value": "4" + }, + "e": { + "type": "integer", + "value": "5" + }, + "f": { + "type": "integer", + "value": "6" + }, + "g": { + "type": "integer", + "value": "7" + }, + "h": { + "type": "integer", + "value": "8" + }, + "i": { + "type": "integer", + "value": "9" + }, + "j": { + "type": "integer", + "value": "10" + }, + "k": { + "type": "integer", + "value": "11" + }, + "l": { + "type": "integer", + "value": "12" + } + }, + "many": { + "dots": { + "here": { + "dot": { + "dot": { + "dot": { + "type": "integer", + "value": "42" + } + } + } + } + } + }, + "name": { + "first": { + "type": "string", + "value": "Arthur" + }, + "last": { + "type": "string", + "value": "Dent" + } + }, + "tbl": { + "a": { + "b": { + "c": { + "type": "float", + "value": "42.666" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/key/dotted.toml b/internal/toml-test/tests/valid/key/dotted.toml new file mode 100644 index 00000000..52d62d72 --- /dev/null +++ b/internal/toml-test/tests/valid/key/dotted.toml @@ -0,0 +1,35 @@ +# Note: this file contains literal tab characters. + +name.first = "Arthur" +"name".'last' = "Dent" + +many.dots.here.dot.dot.dot = 42 + +# Space are ignored, and key parts can be quoted. +count.a = 1 +count . b = 2 +"count"."c" = 3 +"count" . "d" = 4 +'count'.'e' = 5 +'count' . 'f' = 6 +"count".'g' = 7 +"count" . 'h' = 8 +count.'i' = 9 +count . 'j' = 10 +"count".k = 11 +"count" . l = 12 + +[tbl] +a.b.c = 42.666 + +[a.few.dots] +polka.dot = "again?" +polka.dance-with = "Dot" + +[[arr]] +a.b.c=1 +a.b.d=2 + +[[arr]] +a.b.c=3 +a.b.d=4 diff --git a/internal/toml-test/tests/valid/key/empty.json b/internal/toml-test/tests/valid/key/empty.json new file mode 100644 index 00000000..44948a9e --- /dev/null +++ b/internal/toml-test/tests/valid/key/empty.json @@ -0,0 +1,6 @@ +{ + "": { + "type": "string", + "value": "blank" + } +} diff --git a/internal/toml-test/tests/valid/key/empty.toml b/internal/toml-test/tests/valid/key/empty.toml new file mode 100644 index 00000000..0a1640dc --- /dev/null +++ b/internal/toml-test/tests/valid/key/empty.toml @@ -0,0 +1 @@ +"" = "blank" diff --git a/internal/toml-test/tests/valid/key/equals-nospace.json b/internal/toml-test/tests/valid/key/equals-nospace.json new file mode 100644 index 00000000..9394e562 --- /dev/null +++ b/internal/toml-test/tests/valid/key/equals-nospace.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "integer", + "value": "42" + } +} diff --git a/internal/toml-test/tests/valid/key/equals-nospace.toml b/internal/toml-test/tests/valid/key/equals-nospace.toml new file mode 100644 index 00000000..560901c5 --- /dev/null +++ b/internal/toml-test/tests/valid/key/equals-nospace.toml @@ -0,0 +1 @@ +answer=42 diff --git a/internal/toml-test/tests/valid/key/escapes.json b/internal/toml-test/tests/valid/key/escapes.json new file mode 100644 index 00000000..e62b3a14 --- /dev/null +++ b/internal/toml-test/tests/valid/key/escapes.json @@ -0,0 +1,24 @@ +{ + "\n": { + "type": "string", + "value": "newline" + }, + "\"": { + "type": "string", + "value": "just a quote" + }, + "\"quoted\"": { + "quote": { + "type": "bool", + "value": "true" + } + }, + "a.b": { + "À": {} + }, + "backsp\u0008\u0008": {}, + "À": { + "type": "string", + "value": "latin capital letter A with grave" + } +} diff --git a/internal/toml-test/tests/valid/key/escapes.toml b/internal/toml-test/tests/valid/key/escapes.toml new file mode 100644 index 00000000..aac3c0a5 --- /dev/null +++ b/internal/toml-test/tests/valid/key/escapes.toml @@ -0,0 +1,10 @@ +"\n" = "newline" +"\u00c0" = "latin capital letter A with grave" +"\"" = "just a quote" + +["backsp\b\b"] + +["\"quoted\""] +quote = true + +["a.b"."\u00c0"] diff --git a/internal/toml-test/tests/valid/key/numeric-dotted.json b/internal/toml-test/tests/valid/key/numeric-dotted.json new file mode 100644 index 00000000..43dd4d1f --- /dev/null +++ b/internal/toml-test/tests/valid/key/numeric-dotted.json @@ -0,0 +1,8 @@ +{ + "1": { + "2": { + "type": "integer", + "value": "3" + } + } +} diff --git a/internal/toml-test/tests/valid/key/numeric-dotted.toml b/internal/toml-test/tests/valid/key/numeric-dotted.toml new file mode 100644 index 00000000..538204c6 --- /dev/null +++ b/internal/toml-test/tests/valid/key/numeric-dotted.toml @@ -0,0 +1 @@ +1.2 = 3 diff --git a/internal/toml-test/tests/valid/key/numeric.json b/internal/toml-test/tests/valid/key/numeric.json new file mode 100644 index 00000000..eddb88be --- /dev/null +++ b/internal/toml-test/tests/valid/key/numeric.json @@ -0,0 +1,6 @@ +{ + "1": { + "type": "integer", + "value": "1" + } +} diff --git a/internal/toml-test/tests/valid/key/numeric.toml b/internal/toml-test/tests/valid/key/numeric.toml new file mode 100644 index 00000000..532356f4 --- /dev/null +++ b/internal/toml-test/tests/valid/key/numeric.toml @@ -0,0 +1 @@ +1 = 1 diff --git a/internal/toml-test/tests/valid/key/quoted-dots.json b/internal/toml-test/tests/valid/key/quoted-dots.json new file mode 100644 index 00000000..1582c5b8 --- /dev/null +++ b/internal/toml-test/tests/valid/key/quoted-dots.json @@ -0,0 +1,32 @@ +{ + "plain": { + "type": "integer", + "value": "1" + }, + "plain_table": { + "plain": { + "type": "integer", + "value": "3" + }, + "with.dot": { + "type": "integer", + "value": "4" + } + }, + "table": { + "withdot": { + "key.with.dots": { + "type": "integer", + "value": "6" + }, + "plain": { + "type": "integer", + "value": "5" + } + } + }, + "with.dot": { + "type": "integer", + "value": "2" + } +} diff --git a/internal/toml-test/tests/valid/key/quoted-dots.toml b/internal/toml-test/tests/valid/key/quoted-dots.toml new file mode 100644 index 00000000..65fcddf9 --- /dev/null +++ b/internal/toml-test/tests/valid/key/quoted-dots.toml @@ -0,0 +1,10 @@ +plain = 1 +"with.dot" = 2 + +[plain_table] +plain = 3 +"with.dot" = 4 + +[table.withdot] +plain = 5 +"key.with.dots" = 6 diff --git a/internal/toml-test/tests/valid/key/space.json b/internal/toml-test/tests/valid/key/space.json new file mode 100644 index 00000000..6d95f1ad --- /dev/null +++ b/internal/toml-test/tests/valid/key/space.json @@ -0,0 +1,6 @@ +{ + "a b": { + "type": "integer", + "value": "1" + } +} diff --git a/internal/toml-test/tests/valid/key/space.toml b/internal/toml-test/tests/valid/key/space.toml new file mode 100644 index 00000000..f4f36c4f --- /dev/null +++ b/internal/toml-test/tests/valid/key/space.toml @@ -0,0 +1 @@ +"a b" = 1 diff --git a/internal/toml-test/tests/valid/key/special-chars.json b/internal/toml-test/tests/valid/key/special-chars.json new file mode 100644 index 00000000..60840475 --- /dev/null +++ b/internal/toml-test/tests/valid/key/special-chars.json @@ -0,0 +1,6 @@ +{ + "~!@$^\u0026*()_+-`1234567890[]|/?\u003e\u003c.,;:'": { + "type": "integer", + "value": "1" + } +} diff --git a/internal/toml-test/tests/valid/key/special-chars.toml b/internal/toml-test/tests/valid/key/special-chars.toml new file mode 100644 index 00000000..cc572bef --- /dev/null +++ b/internal/toml-test/tests/valid/key/special-chars.toml @@ -0,0 +1 @@ +"~!@$^&*()_+-`1234567890[]|/?><.,;:'" = 1 diff --git a/internal/toml-test/tests/valid/key/special-word.json b/internal/toml-test/tests/valid/key/special-word.json new file mode 100644 index 00000000..59ce693a --- /dev/null +++ b/internal/toml-test/tests/valid/key/special-word.json @@ -0,0 +1,18 @@ +{ + "false": { + "type": "bool", + "value": "false" + }, + "inf": { + "type": "integer", + "value": "100000000" + }, + "nan": { + "type": "string", + "value": "ceci n'est pas un nombre" + }, + "true": { + "type": "integer", + "value": "1" + } +} diff --git a/internal/toml-test/tests/valid/key/special-word.toml b/internal/toml-test/tests/valid/key/special-word.toml new file mode 100644 index 00000000..0b836f17 --- /dev/null +++ b/internal/toml-test/tests/valid/key/special-word.toml @@ -0,0 +1,5 @@ +false = false +true = 1 +inf = 100000000 +nan = "ceci n'est pas un nombre" + diff --git a/internal/toml-test/tests/valid/newline-crlf.json b/internal/toml-test/tests/valid/newline-crlf.json new file mode 100644 index 00000000..acf617e3 --- /dev/null +++ b/internal/toml-test/tests/valid/newline-crlf.json @@ -0,0 +1,10 @@ +{ + "newline": { + "type": "string", + "value": "crlf" + }, + "os": { + "type": "string", + "value": "DOS" + } +} diff --git a/internal/toml-test/tests/valid/newline-crlf.toml b/internal/toml-test/tests/valid/newline-crlf.toml new file mode 100644 index 00000000..00300244 --- /dev/null +++ b/internal/toml-test/tests/valid/newline-crlf.toml @@ -0,0 +1,2 @@ +os = "DOS" +newline = "crlf" diff --git a/internal/toml-test/tests/valid/newline-lf.json b/internal/toml-test/tests/valid/newline-lf.json new file mode 100644 index 00000000..66cf871f --- /dev/null +++ b/internal/toml-test/tests/valid/newline-lf.json @@ -0,0 +1,10 @@ +{ + "newline": { + "type": "string", + "value": "lf" + }, + "os": { + "type": "string", + "value": "unix" + } +} diff --git a/internal/toml-test/tests/valid/newline-lf.toml b/internal/toml-test/tests/valid/newline-lf.toml new file mode 100644 index 00000000..0f3377cd --- /dev/null +++ b/internal/toml-test/tests/valid/newline-lf.toml @@ -0,0 +1,2 @@ +os = "unix" +newline = "lf" diff --git a/internal/toml-test/tests/valid/spec-example-1-compact.json b/internal/toml-test/tests/valid/spec-example-1-compact.json new file mode 100644 index 00000000..9f4078aa --- /dev/null +++ b/internal/toml-test/tests/valid/spec-example-1-compact.json @@ -0,0 +1,100 @@ +{ + "clients": { + "data": [ + [ + { + "type": "string", + "value": "gamma" + }, + { + "type": "string", + "value": "delta" + } + ], + [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ] + ], + "hosts": [ + { + "type": "string", + "value": "alpha" + }, + { + "type": "string", + "value": "omega" + } + ] + }, + "database": { + "connection_max": { + "type": "integer", + "value": "5000" + }, + "enabled": { + "type": "bool", + "value": "true" + }, + "ports": [ + { + "type": "integer", + "value": "8001" + }, + { + "type": "integer", + "value": "8001" + }, + { + "type": "integer", + "value": "8002" + } + ], + "server": { + "type": "string", + "value": "192.168.1.1" + } + }, + "owner": { + "dob": { + "type": "datetime", + "value": "1979-05-27T07:32:00-08:00" + }, + "name": { + "type": "string", + "value": "Lance Uppercut" + } + }, + "servers": { + "alpha": { + "dc": { + "type": "string", + "value": "eqdc10" + }, + "ip": { + "type": "string", + "value": "10.0.0.1" + } + }, + "beta": { + "dc": { + "type": "string", + "value": "eqdc10" + }, + "ip": { + "type": "string", + "value": "10.0.0.2" + } + } + }, + "title": { + "type": "string", + "value": "TOML Example" + } +} diff --git a/internal/toml-test/tests/valid/spec-example-1-compact.toml b/internal/toml-test/tests/valid/spec-example-1-compact.toml new file mode 100644 index 00000000..15e2b84b --- /dev/null +++ b/internal/toml-test/tests/valid/spec-example-1-compact.toml @@ -0,0 +1,23 @@ +#Useless spaces eliminated. +title="TOML Example" +[owner] +name="Lance Uppercut" +dob=1979-05-27T07:32:00-08:00#First class dates +[database] +server="192.168.1.1" +ports=[8001,8001,8002] +connection_max=5000 +enabled=true +[servers] +[servers.alpha] +ip="10.0.0.1" +dc="eqdc10" +[servers.beta] +ip="10.0.0.2" +dc="eqdc10" +[clients] +data=[["gamma","delta"],[1,2]] +hosts=[ +"alpha", +"omega" +] diff --git a/internal/toml-test/tests/valid/spec-example-1.json b/internal/toml-test/tests/valid/spec-example-1.json new file mode 100644 index 00000000..9f4078aa --- /dev/null +++ b/internal/toml-test/tests/valid/spec-example-1.json @@ -0,0 +1,100 @@ +{ + "clients": { + "data": [ + [ + { + "type": "string", + "value": "gamma" + }, + { + "type": "string", + "value": "delta" + } + ], + [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ] + ], + "hosts": [ + { + "type": "string", + "value": "alpha" + }, + { + "type": "string", + "value": "omega" + } + ] + }, + "database": { + "connection_max": { + "type": "integer", + "value": "5000" + }, + "enabled": { + "type": "bool", + "value": "true" + }, + "ports": [ + { + "type": "integer", + "value": "8001" + }, + { + "type": "integer", + "value": "8001" + }, + { + "type": "integer", + "value": "8002" + } + ], + "server": { + "type": "string", + "value": "192.168.1.1" + } + }, + "owner": { + "dob": { + "type": "datetime", + "value": "1979-05-27T07:32:00-08:00" + }, + "name": { + "type": "string", + "value": "Lance Uppercut" + } + }, + "servers": { + "alpha": { + "dc": { + "type": "string", + "value": "eqdc10" + }, + "ip": { + "type": "string", + "value": "10.0.0.1" + } + }, + "beta": { + "dc": { + "type": "string", + "value": "eqdc10" + }, + "ip": { + "type": "string", + "value": "10.0.0.2" + } + } + }, + "title": { + "type": "string", + "value": "TOML Example" + } +} diff --git a/internal/toml-test/tests/valid/spec-example-1.toml b/internal/toml-test/tests/valid/spec-example-1.toml new file mode 100644 index 00000000..52fd1e89 --- /dev/null +++ b/internal/toml-test/tests/valid/spec-example-1.toml @@ -0,0 +1,33 @@ +# This is a TOML document. Boom. + +title = "TOML Example" + +[owner] +name = "Lance Uppercut" +dob = 1979-05-27T07:32:00-08:00 # First class dates? Why not? + +[database] +server = "192.168.1.1" +ports = [ 8001, 8001, 8002 ] +connection_max = 5000 +enabled = true + +[servers] + + # You can indent as you please. Tabs or spaces. TOML don't care. + [servers.alpha] + ip = "10.0.0.1" + dc = "eqdc10" + + [servers.beta] + ip = "10.0.0.2" + dc = "eqdc10" + +[clients] +data = [ ["gamma", "delta"], [1, 2] ] + +# Line breaks are OK when inside arrays +hosts = [ + "alpha", + "omega" +] diff --git a/internal/toml-test/tests/valid/string/double-quote-escape.json b/internal/toml-test/tests/valid/string/double-quote-escape.json new file mode 100644 index 00000000..0c4ac37e --- /dev/null +++ b/internal/toml-test/tests/valid/string/double-quote-escape.json @@ -0,0 +1,6 @@ +{ + "test": { + "type": "string", + "value": "\"one\"" + } +} diff --git a/internal/toml-test/tests/valid/string/double-quote-escape.toml b/internal/toml-test/tests/valid/string/double-quote-escape.toml new file mode 100644 index 00000000..78e7e729 --- /dev/null +++ b/internal/toml-test/tests/valid/string/double-quote-escape.toml @@ -0,0 +1 @@ +test = "\"one\"" diff --git a/internal/toml-test/tests/valid/string/empty.json b/internal/toml-test/tests/valid/string/empty.json new file mode 100644 index 00000000..efe96c36 --- /dev/null +++ b/internal/toml-test/tests/valid/string/empty.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "string", + "value": "" + } +} diff --git a/internal/toml-test/tests/valid/string/empty.toml b/internal/toml-test/tests/valid/string/empty.toml new file mode 100644 index 00000000..e37e6815 --- /dev/null +++ b/internal/toml-test/tests/valid/string/empty.toml @@ -0,0 +1 @@ +answer = "" diff --git a/internal/toml-test/tests/valid/string/escape-tricky.json b/internal/toml-test/tests/valid/string/escape-tricky.json new file mode 100644 index 00000000..572e0a56 --- /dev/null +++ b/internal/toml-test/tests/valid/string/escape-tricky.json @@ -0,0 +1,30 @@ +{ + "end_esc": { + "type": "string", + "value": "String does not end here\" but ends here\\" + }, + "lit_end_esc": { + "type": "string", + "value": "String ends here\\" + }, + "lit_multiline_end": { + "type": "string", + "value": "There is no escape\\" + }, + "lit_multiline_not_unicode": { + "type": "string", + "value": "\\u007f" + }, + "multiline_end_esc": { + "type": "string", + "value": "When will it end? \"\"\"...\"\"\" should be here\"" + }, + "multiline_not_unicode": { + "type": "string", + "value": "\\u0041" + }, + "multiline_unicode": { + "type": "string", + "value": " " + } +} diff --git a/internal/toml-test/tests/valid/string/escape-tricky.toml b/internal/toml-test/tests/valid/string/escape-tricky.toml new file mode 100644 index 00000000..dc204cb3 --- /dev/null +++ b/internal/toml-test/tests/valid/string/escape-tricky.toml @@ -0,0 +1,15 @@ +end_esc = "String does not end here\" but ends here\\" +lit_end_esc = 'String ends here\' + +multiline_unicode = """ +\u00a0""" + +multiline_not_unicode = """ +\\u0041""" + +multiline_end_esc = """When will it end? \"""...""\" should be here\"""" + +lit_multiline_not_unicode = ''' +\u007f''' + +lit_multiline_end = '''There is no escape\''' diff --git a/internal/toml-test/tests/valid/string/escaped-escape.json b/internal/toml-test/tests/valid/string/escaped-escape.json new file mode 100644 index 00000000..112c0c97 --- /dev/null +++ b/internal/toml-test/tests/valid/string/escaped-escape.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "string", + "value": "\\x64" + } +} diff --git a/internal/toml-test/tests/valid/string/escaped-escape.toml b/internal/toml-test/tests/valid/string/escaped-escape.toml new file mode 100644 index 00000000..d5758761 --- /dev/null +++ b/internal/toml-test/tests/valid/string/escaped-escape.toml @@ -0,0 +1 @@ +answer = "\\x64" diff --git a/internal/toml-test/tests/valid/string/escapes.json b/internal/toml-test/tests/valid/string/escapes.json new file mode 100644 index 00000000..d849574a --- /dev/null +++ b/internal/toml-test/tests/valid/string/escapes.json @@ -0,0 +1,54 @@ +{ + "backslash": { + "type": "string", + "value": "This string has a \\ backslash character." + }, + "backspace": { + "type": "string", + "value": "This string has a \u0008 backspace character." + }, + "carriage": { + "type": "string", + "value": "This string has a \r carriage return character." + }, + "delete": { + "type": "string", + "value": "This string has a  delete control code." + }, + "formfeed": { + "type": "string", + "value": "This string has a \u000c form feed character." + }, + "newline": { + "type": "string", + "value": "This string has a \n new line character." + }, + "notunicode1": { + "type": "string", + "value": "This string does not have a unicode \\u escape." + }, + "notunicode2": { + "type": "string", + "value": "This string does not have a unicode \\u escape." + }, + "notunicode3": { + "type": "string", + "value": "This string does not have a unicode \\u0075 escape." + }, + "notunicode4": { + "type": "string", + "value": "This string does not have a unicode \\u escape." + }, + "quote": { + "type": "string", + "value": "This string has a \" quote character." + }, + "tab": { + "type": "string", + "value": "This string has a \t tab character." + }, + "unitseparator": { + "type": "string", + "value": "This string has a \u001f unit separator control code." + } +} diff --git a/internal/toml-test/tests/valid/string/escapes.toml b/internal/toml-test/tests/valid/string/escapes.toml new file mode 100644 index 00000000..78f7ebdf --- /dev/null +++ b/internal/toml-test/tests/valid/string/escapes.toml @@ -0,0 +1,13 @@ +backspace = "This string has a \b backspace character." +tab = "This string has a \t tab character." +newline = "This string has a \n new line character." +formfeed = "This string has a \f form feed character." +carriage = "This string has a \r carriage return character." +quote = "This string has a \" quote character." +backslash = "This string has a \\ backslash character." +notunicode1 = "This string does not have a unicode \\u escape." +notunicode2 = "This string does not have a unicode \u005Cu escape." +notunicode3 = "This string does not have a unicode \\u0075 escape." +notunicode4 = "This string does not have a unicode \\\u0075 escape." +delete = "This string has a \u007F delete control code." +unitseparator = "This string has a \u001F unit separator control code." diff --git a/internal/toml-test/tests/valid/string/multiline-json b/internal/toml-test/tests/valid/string/multiline-json new file mode 100644 index 00000000..66e572bd --- /dev/null +++ b/internal/toml-test/tests/valid/string/multiline-json @@ -0,0 +1,54 @@ +{ + "equivalent_one": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + }, + "equivalent_three": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + }, + "equivalent_two": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + }, + "escape-bs-1": { + "type": "string", + "value": "a \\\nb" + }, + "escape-bs-2": { + "type": "string", + "value": "a \\b" + }, + "escape-bs-3": { + "type": "string", + "value": "a \\\\\n b" + }, + "keep-ws-before": { + "type": "string", + "value": "a \tb" + }, + "multiline_empty_four": { + "type": "string", + "value": "" + }, + "multiline_empty_one": { + "type": "string", + "value": "" + }, + "multiline_empty_three": { + "type": "string", + "value": "" + }, + "multiline_empty_two": { + "type": "string", + "value": "" + }, + "no-space": { + "type": "string", + "value": "ab" + }, + "whitespace-after-bs": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + } +} diff --git a/internal/toml-test/tests/valid/string/multiline-quotes.json b/internal/toml-test/tests/valid/string/multiline-quotes.json new file mode 100644 index 00000000..c134f671 --- /dev/null +++ b/internal/toml-test/tests/valid/string/multiline-quotes.json @@ -0,0 +1,42 @@ +{ + "lit_one": { + "type": "string", + "value": "'one quote'" + }, + "lit_one_space": { + "type": "string", + "value": " 'one quote' " + }, + "lit_two": { + "type": "string", + "value": "''two quotes''" + }, + "lit_two_space": { + "type": "string", + "value": " ''two quotes'' " + }, + "mismatch1": { + "type": "string", + "value": "aaa'''bbb" + }, + "mismatch2": { + "type": "string", + "value": "aaa\"\"\"bbb" + }, + "one": { + "type": "string", + "value": "\"one quote\"" + }, + "one_space": { + "type": "string", + "value": " \"one quote\" " + }, + "two": { + "type": "string", + "value": "\"\"two quotes\"\"" + }, + "two_space": { + "type": "string", + "value": " \"\"two quotes\"\" " + } +} diff --git a/internal/toml-test/tests/valid/string/multiline-quotes.toml b/internal/toml-test/tests/valid/string/multiline-quotes.toml new file mode 100644 index 00000000..e138e2fa --- /dev/null +++ b/internal/toml-test/tests/valid/string/multiline-quotes.toml @@ -0,0 +1,15 @@ +# Make sure that quotes inside multiline strings are allowed, including right +# after the opening '''/""" and before the closing '''/""" + +lit_one = ''''one quote'''' +lit_two = '''''two quotes''''' +lit_one_space = ''' 'one quote' ''' +lit_two_space = ''' ''two quotes'' ''' + +one = """"one quote"""" +two = """""two quotes""""" +one_space = """ "one quote" """ +two_space = """ ""two quotes"" """ + +mismatch1 = """aaa'''bbb""" +mismatch2 = '''aaa"""bbb''' diff --git a/internal/toml-test/tests/valid/string/multiline-toml b/internal/toml-test/tests/valid/string/multiline-toml new file mode 100644 index 00000000..07048483 --- /dev/null +++ b/internal/toml-test/tests/valid/string/multiline-toml @@ -0,0 +1,46 @@ +# NOTE: this file includes some literal tab characters. + +multiline_empty_one = """""" +multiline_empty_two = """ +""" +multiline_empty_three = """\ + """ +multiline_empty_four = """\ + \ + \ + """ + +equivalent_one = "The quick brown fox jumps over the lazy dog." +equivalent_two = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" + +equivalent_three = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ + +whitespace-after-bs = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ + +no-space = """a\ + b""" + +keep-ws-before = """a \ + b""" + +escape-bs-1 = """a \\ +b""" + +escape-bs-2 = """a \\\ +b""" + +escape-bs-3 = """a \\\\ + b""" diff --git a/internal/toml-test/tests/valid/string/nl.json b/internal/toml-test/tests/valid/string/nl.json new file mode 100644 index 00000000..8eae09a0 --- /dev/null +++ b/internal/toml-test/tests/valid/string/nl.json @@ -0,0 +1,22 @@ +{ + "lit_nl_end": { + "type": "string", + "value": "value\\n" + }, + "lit_nl_mid": { + "type": "string", + "value": "val\\nue" + }, + "lit_nl_uni": { + "type": "string", + "value": "val\\ue" + }, + "nl_end": { + "type": "string", + "value": "value\n" + }, + "nl_mid": { + "type": "string", + "value": "val\nue" + } +} diff --git a/internal/toml-test/tests/valid/string/nl.toml b/internal/toml-test/tests/valid/string/nl.toml new file mode 100644 index 00000000..1e09a8bf --- /dev/null +++ b/internal/toml-test/tests/valid/string/nl.toml @@ -0,0 +1,6 @@ +nl_mid = "val\nue" +nl_end = """value\n""" + +lit_nl_end = '''value\n''' +lit_nl_mid = 'val\nue' +lit_nl_uni = 'val\ue' diff --git a/internal/toml-test/tests/valid/string/raw-multiline.json b/internal/toml-test/tests/valid/string/raw-multiline.json new file mode 100644 index 00000000..4d195ec5 --- /dev/null +++ b/internal/toml-test/tests/valid/string/raw-multiline.json @@ -0,0 +1,14 @@ +{ + "firstnl": { + "type": "string", + "value": "This string has a ' quote character." + }, + "multiline": { + "type": "string", + "value": "This string\nhas ' a quote character\nand more than\none newline\nin it." + }, + "oneline": { + "type": "string", + "value": "This string has a ' quote character." + } +} diff --git a/internal/toml-test/tests/valid/string/raw-multiline.toml b/internal/toml-test/tests/valid/string/raw-multiline.toml new file mode 100644 index 00000000..8094c03e --- /dev/null +++ b/internal/toml-test/tests/valid/string/raw-multiline.toml @@ -0,0 +1,9 @@ +oneline = '''This string has a ' quote character.''' +firstnl = ''' +This string has a ' quote character.''' +multiline = ''' +This string +has ' a quote character +and more than +one newline +in it.''' diff --git a/internal/toml-test/tests/valid/string/raw.json b/internal/toml-test/tests/valid/string/raw.json new file mode 100644 index 00000000..6b753a35 --- /dev/null +++ b/internal/toml-test/tests/valid/string/raw.json @@ -0,0 +1,30 @@ +{ + "backslash": { + "type": "string", + "value": "This string has a \\\\ backslash character." + }, + "backspace": { + "type": "string", + "value": "This string has a \\b backspace character." + }, + "carriage": { + "type": "string", + "value": "This string has a \\r carriage return character." + }, + "formfeed": { + "type": "string", + "value": "This string has a \\f form feed character." + }, + "newline": { + "type": "string", + "value": "This string has a \\n new line character." + }, + "slash": { + "type": "string", + "value": "This string has a \\/ slash character." + }, + "tab": { + "type": "string", + "value": "This string has a \\t tab character." + } +} diff --git a/internal/toml-test/tests/valid/string/raw.toml b/internal/toml-test/tests/valid/string/raw.toml new file mode 100644 index 00000000..92acd255 --- /dev/null +++ b/internal/toml-test/tests/valid/string/raw.toml @@ -0,0 +1,7 @@ +backspace = 'This string has a \b backspace character.' +tab = 'This string has a \t tab character.' +newline = 'This string has a \n new line character.' +formfeed = 'This string has a \f form feed character.' +carriage = 'This string has a \r carriage return character.' +slash = 'This string has a \/ slash character.' +backslash = 'This string has a \\ backslash character.' diff --git a/internal/toml-test/tests/valid/string/simple.json b/internal/toml-test/tests/valid/string/simple.json new file mode 100644 index 00000000..2561cda3 --- /dev/null +++ b/internal/toml-test/tests/valid/string/simple.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "string", + "value": "You are not drinking enough whisky." + } +} diff --git a/internal/toml-test/tests/valid/string/simple.toml b/internal/toml-test/tests/valid/string/simple.toml new file mode 100644 index 00000000..e17ade62 --- /dev/null +++ b/internal/toml-test/tests/valid/string/simple.toml @@ -0,0 +1 @@ +answer = "You are not drinking enough whisky." diff --git a/internal/toml-test/tests/valid/string/unicode-escape.json b/internal/toml-test/tests/valid/string/unicode-escape.json new file mode 100644 index 00000000..9ae728ba --- /dev/null +++ b/internal/toml-test/tests/valid/string/unicode-escape.json @@ -0,0 +1,10 @@ +{ + "answer4": { + "type": "string", + "value": "δ" + }, + "answer8": { + "type": "string", + "value": "δ" + } +} diff --git a/internal/toml-test/tests/valid/string/unicode-escape.toml b/internal/toml-test/tests/valid/string/unicode-escape.toml new file mode 100644 index 00000000..82faecbf --- /dev/null +++ b/internal/toml-test/tests/valid/string/unicode-escape.toml @@ -0,0 +1,2 @@ +answer4 = "\u03B4" +answer8 = "\U000003B4" diff --git a/internal/toml-test/tests/valid/string/unicode-literal.json b/internal/toml-test/tests/valid/string/unicode-literal.json new file mode 100644 index 00000000..7f15df42 --- /dev/null +++ b/internal/toml-test/tests/valid/string/unicode-literal.json @@ -0,0 +1,6 @@ +{ + "answer": { + "type": "string", + "value": "δ" + } +} diff --git a/internal/toml-test/tests/valid/string/unicode-literal.toml b/internal/toml-test/tests/valid/string/unicode-literal.toml new file mode 100644 index 00000000..c65723ca --- /dev/null +++ b/internal/toml-test/tests/valid/string/unicode-literal.toml @@ -0,0 +1 @@ +answer = "δ" diff --git a/internal/toml-test/tests/valid/string/with-pound.json b/internal/toml-test/tests/valid/string/with-pound.json new file mode 100644 index 00000000..2cb8beb9 --- /dev/null +++ b/internal/toml-test/tests/valid/string/with-pound.json @@ -0,0 +1,10 @@ +{ + "pound": { + "type": "string", + "value": "We see no # comments here." + }, + "poundcomment": { + "type": "string", + "value": "But there are # some comments here." + } +} diff --git a/internal/toml-test/tests/valid/string/with-pound.toml b/internal/toml-test/tests/valid/string/with-pound.toml new file mode 100644 index 00000000..5fd87466 --- /dev/null +++ b/internal/toml-test/tests/valid/string/with-pound.toml @@ -0,0 +1,2 @@ +pound = "We see no # comments here." +poundcomment = "But there are # some comments here." # Did I # mess you up? diff --git a/internal/toml-test/tests/valid/table/array-implicit.json b/internal/toml-test/tests/valid/table/array-implicit.json new file mode 100644 index 00000000..ee164c5f --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-implicit.json @@ -0,0 +1,12 @@ +{ + "albums": { + "songs": [ + { + "name": { + "type": "string", + "value": "Glory Days" + } + } + ] + } +} diff --git a/internal/toml-test/tests/valid/table/array-implicit.toml b/internal/toml-test/tests/valid/table/array-implicit.toml new file mode 100644 index 00000000..3157ac98 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-implicit.toml @@ -0,0 +1,2 @@ +[[albums.songs]] +name = "Glory Days" diff --git a/internal/toml-test/tests/valid/table/array-many.json b/internal/toml-test/tests/valid/table/array-many.json new file mode 100644 index 00000000..fe78bf6b --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-many.json @@ -0,0 +1,34 @@ +{ + "people": [ + { + "first_name": { + "type": "string", + "value": "Bruce" + }, + "last_name": { + "type": "string", + "value": "Springsteen" + } + }, + { + "first_name": { + "type": "string", + "value": "Eric" + }, + "last_name": { + "type": "string", + "value": "Clapton" + } + }, + { + "first_name": { + "type": "string", + "value": "Bob" + }, + "last_name": { + "type": "string", + "value": "Seger" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/table/array-many.toml b/internal/toml-test/tests/valid/table/array-many.toml new file mode 100644 index 00000000..46062beb --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-many.toml @@ -0,0 +1,11 @@ +[[people]] +first_name = "Bruce" +last_name = "Springsteen" + +[[people]] +first_name = "Eric" +last_name = "Clapton" + +[[people]] +first_name = "Bob" +last_name = "Seger" diff --git a/internal/toml-test/tests/valid/table/array-nest.json b/internal/toml-test/tests/valid/table/array-nest.json new file mode 100644 index 00000000..97f55c81 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-nest.json @@ -0,0 +1,44 @@ +{ + "albums": [ + { + "name": { + "type": "string", + "value": "Born to Run" + }, + "songs": [ + { + "name": { + "type": "string", + "value": "Jungleland" + } + }, + { + "name": { + "type": "string", + "value": "Meeting Across the River" + } + } + ] + }, + { + "name": { + "type": "string", + "value": "Born in the USA" + }, + "songs": [ + { + "name": { + "type": "string", + "value": "Glory Days" + } + }, + { + "name": { + "type": "string", + "value": "Dancing in the Dark" + } + } + ] + } + ] +} diff --git a/internal/toml-test/tests/valid/table/array-nest.toml b/internal/toml-test/tests/valid/table/array-nest.toml new file mode 100644 index 00000000..d659a3d9 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-nest.toml @@ -0,0 +1,17 @@ +[[albums]] +name = "Born to Run" + + [[albums.songs]] + name = "Jungleland" + + [[albums.songs]] + name = "Meeting Across the River" + +[[albums]] +name = "Born in the USA" + + [[albums.songs]] + name = "Glory Days" + + [[albums.songs]] + name = "Dancing in the Dark" diff --git a/internal/toml-test/tests/valid/table/array-one.json b/internal/toml-test/tests/valid/table/array-one.json new file mode 100644 index 00000000..5cd67de1 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-one.json @@ -0,0 +1,14 @@ +{ + "people": [ + { + "first_name": { + "type": "string", + "value": "Bruce" + }, + "last_name": { + "type": "string", + "value": "Springsteen" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/table/array-one.toml b/internal/toml-test/tests/valid/table/array-one.toml new file mode 100644 index 00000000..cd7e1b69 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-one.toml @@ -0,0 +1,3 @@ +[[people]] +first_name = "Bruce" +last_name = "Springsteen" diff --git a/internal/toml-test/tests/valid/table/array-table-array.json b/internal/toml-test/tests/valid/table/array-table-array.json new file mode 100644 index 00000000..5c3d6495 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-table-array.json @@ -0,0 +1,24 @@ +{ + "a": [ + { + "b": [ + { + "c": { + "d": { + "type": "string", + "value": "val0" + } + } + }, + { + "c": { + "d": { + "type": "string", + "value": "val1" + } + } + } + ] + } + ] +} diff --git a/internal/toml-test/tests/valid/table/array-table-array.toml b/internal/toml-test/tests/valid/table/array-table-array.toml new file mode 100644 index 00000000..a07b0c7f --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-table-array.toml @@ -0,0 +1,7 @@ +[[a]] + [[a.b]] + [a.b.c] + d = "val0" + [[a.b]] + [a.b.c] + d = "val1" diff --git a/internal/toml-test/tests/valid/table/empty.json b/internal/toml-test/tests/valid/table/empty.json new file mode 100644 index 00000000..3e82cdad --- /dev/null +++ b/internal/toml-test/tests/valid/table/empty.json @@ -0,0 +1,3 @@ +{ + "a": {} +} diff --git a/internal/toml-test/tests/valid/table/empty.toml b/internal/toml-test/tests/valid/table/empty.toml new file mode 100644 index 00000000..8bb6a0aa --- /dev/null +++ b/internal/toml-test/tests/valid/table/empty.toml @@ -0,0 +1 @@ +[a] diff --git a/internal/toml-test/tests/valid/table/keyword.json b/internal/toml-test/tests/valid/table/keyword.json new file mode 100644 index 00000000..a15dfae0 --- /dev/null +++ b/internal/toml-test/tests/valid/table/keyword.json @@ -0,0 +1,6 @@ +{ + "true": {}, + "false": {}, + "inf": {}, + "nan": {} +} diff --git a/internal/toml-test/tests/valid/table/keyword.toml b/internal/toml-test/tests/valid/table/keyword.toml new file mode 100644 index 00000000..bc3d52a7 --- /dev/null +++ b/internal/toml-test/tests/valid/table/keyword.toml @@ -0,0 +1,9 @@ +[true] + +[false] + +[inf] + +[nan] + + diff --git a/internal/toml-test/tests/valid/table/names.json b/internal/toml-test/tests/valid/table/names.json new file mode 100644 index 00000000..66d8ea5b --- /dev/null +++ b/internal/toml-test/tests/valid/table/names.json @@ -0,0 +1,30 @@ +{ + "a": { + " x ": {}, + "b": { + "c": {} + }, + "b.c": {}, + "d.e": {} + }, + "d": { + "e": { + "f": {} + } + }, + "g": { + "h": { + "i": {} + } + }, + "j": { + "Êž": { + "l": {} + } + }, + "x": { + "1": { + "2": {} + } + } +} diff --git a/internal/toml-test/tests/valid/table/names.toml b/internal/toml-test/tests/valid/table/names.toml new file mode 100644 index 00000000..092da2ff --- /dev/null +++ b/internal/toml-test/tests/valid/table/names.toml @@ -0,0 +1,9 @@ +[a.b.c] +[a."b.c"] +[a.'d.e'] +[a.' x '] +[ d.e.f ] +[ g . h . i ] +[ j . "Êž" . 'l' ] + +[x.1.2] diff --git a/internal/toml-test/tests/valid/table/no-eol.json b/internal/toml-test/tests/valid/table/no-eol.json new file mode 100644 index 00000000..b6e7fb50 --- /dev/null +++ b/internal/toml-test/tests/valid/table/no-eol.json @@ -0,0 +1,3 @@ +{ + "table": {} +} diff --git a/internal/toml-test/tests/valid/table/no-eol.toml b/internal/toml-test/tests/valid/table/no-eol.toml new file mode 100644 index 00000000..f1098fda --- /dev/null +++ b/internal/toml-test/tests/valid/table/no-eol.toml @@ -0,0 +1 @@ +[table] diff --git a/internal/toml-test/tests/valid/table/sub-empty.json b/internal/toml-test/tests/valid/table/sub-empty.json new file mode 100644 index 00000000..ed10cd23 --- /dev/null +++ b/internal/toml-test/tests/valid/table/sub-empty.json @@ -0,0 +1,5 @@ +{ + "a": { + "b": {} + } +} diff --git a/internal/toml-test/tests/valid/table/sub-empty.toml b/internal/toml-test/tests/valid/table/sub-empty.toml new file mode 100644 index 00000000..70b7fe11 --- /dev/null +++ b/internal/toml-test/tests/valid/table/sub-empty.toml @@ -0,0 +1,2 @@ +[a] +[a.b] diff --git a/internal/toml-test/tests/valid/table/whitespace.json b/internal/toml-test/tests/valid/table/whitespace.json new file mode 100644 index 00000000..c7704703 --- /dev/null +++ b/internal/toml-test/tests/valid/table/whitespace.json @@ -0,0 +1,3 @@ +{ + "valid key": {} +} diff --git a/internal/toml-test/tests/valid/table/whitespace.toml b/internal/toml-test/tests/valid/table/whitespace.toml new file mode 100644 index 00000000..daf881d1 --- /dev/null +++ b/internal/toml-test/tests/valid/table/whitespace.toml @@ -0,0 +1 @@ +["valid key"] diff --git a/internal/toml-test/tests/valid/table/with-literal-string.json b/internal/toml-test/tests/valid/table/with-literal-string.json new file mode 100644 index 00000000..7784695c --- /dev/null +++ b/internal/toml-test/tests/valid/table/with-literal-string.json @@ -0,0 +1,12 @@ +{ + "a": { + "\"b\"": { + "c": { + "answer": { + "type": "integer", + "value": "42" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/table/with-literal-string.toml b/internal/toml-test/tests/valid/table/with-literal-string.toml new file mode 100644 index 00000000..b81643da --- /dev/null +++ b/internal/toml-test/tests/valid/table/with-literal-string.toml @@ -0,0 +1,4 @@ +['a'] +[a.'"b"'] +[a.'"b"'.c] +answer = 42 diff --git a/internal/toml-test/tests/valid/table/with-pound.json b/internal/toml-test/tests/valid/table/with-pound.json new file mode 100644 index 00000000..f32d2f2e --- /dev/null +++ b/internal/toml-test/tests/valid/table/with-pound.json @@ -0,0 +1,8 @@ +{ + "key#group": { + "answer": { + "type": "integer", + "value": "42" + } + } +} diff --git a/internal/toml-test/tests/valid/table/with-pound.toml b/internal/toml-test/tests/valid/table/with-pound.toml new file mode 100644 index 00000000..33f2c4fd --- /dev/null +++ b/internal/toml-test/tests/valid/table/with-pound.toml @@ -0,0 +1,2 @@ +["key#group"] +answer = 42 diff --git a/internal/toml-test/tests/valid/table/with-single-quotes.json b/internal/toml-test/tests/valid/table/with-single-quotes.json new file mode 100644 index 00000000..347c693c --- /dev/null +++ b/internal/toml-test/tests/valid/table/with-single-quotes.json @@ -0,0 +1,12 @@ +{ + "a": { + "b": { + "c": { + "answer": { + "type": "integer", + "value": "42" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/table/with-single-quotes.toml b/internal/toml-test/tests/valid/table/with-single-quotes.toml new file mode 100644 index 00000000..56e52cc9 --- /dev/null +++ b/internal/toml-test/tests/valid/table/with-single-quotes.toml @@ -0,0 +1,4 @@ +['a'] +[a.'b'] +[a.'b'.c] +answer = 42 diff --git a/internal/toml-test/tests/valid/table/without-super.json b/internal/toml-test/tests/valid/table/without-super.json new file mode 100644 index 00000000..3c390c68 --- /dev/null +++ b/internal/toml-test/tests/valid/table/without-super.json @@ -0,0 +1,9 @@ +{ + "x": { + "y": { + "z": { + "w": {} + } + } + } +} diff --git a/internal/toml-test/tests/valid/table/without-super.toml b/internal/toml-test/tests/valid/table/without-super.toml new file mode 100644 index 00000000..73ed68b2 --- /dev/null +++ b/internal/toml-test/tests/valid/table/without-super.toml @@ -0,0 +1,5 @@ +# [x] you +# [x.y] don't +# [x.y.z] need these +[x.y.z.w] # for this to work +[x] # defining a super-table afterwards is ok diff --git a/internal/toml-test/toml.go b/internal/toml-test/toml.go new file mode 100644 index 00000000..78e8de2b --- /dev/null +++ b/internal/toml-test/toml.go @@ -0,0 +1,133 @@ +// +build go1.16 + +package tomltest + +import ( + "math" + "reflect" +) + +// cmpTOML consumes the recursive structure of both want and have +// simultaneously. If anything is unequal the result has failed and comparison +// stops. +// +// reflect.DeepEqual could work here, but it won't tell us how the two +// structures are different. +func (r Test) cmpTOML(want, have interface{}) Test { + if isTomlValue(want) { + if !isTomlValue(have) { + return r.fail("Type for key '%s' differs:\n"+ + " Expected: %[2]v (%[2]T)\n"+ + " Your encoder: %[3]v (%[3]T)", + r.Key, want, have) + } + + if !deepEqual(want, have) { + return r.fail("Values for key '%s' differ:\n"+ + " Expected: %[2]v (%[2]T)\n"+ + " Your encoder: %[3]v (%[3]T)", + r.Key, want, have) + } + return r + } + + switch w := want.(type) { + case map[string]interface{}: + return r.cmpTOMLMap(w, have) + case []interface{}: + return r.cmpTOMLArrays(w, have) + default: + return r.fail("Unrecognized TOML structure: %T", want) + } +} + +func (r Test) cmpTOMLMap(want map[string]interface{}, have interface{}) Test { + haveMap, ok := have.(map[string]interface{}) + if !ok { + return r.mismatch("table", want, haveMap) + } + + // Check that the keys of each map are equivalent. + for k := range want { + if _, ok := haveMap[k]; !ok { + bunk := r.kjoin(k) + return bunk.fail("Could not find key '%s' in encoder output", bunk.Key) + } + } + for k := range haveMap { + if _, ok := want[k]; !ok { + bunk := r.kjoin(k) + return bunk.fail("Could not find key '%s' in expected output", bunk.Key) + } + } + + // Okay, now make sure that each value is equivalent. + for k := range want { + if sub := r.kjoin(k).cmpTOML(want[k], haveMap[k]); sub.Failed() { + return sub + } + } + return r +} + +func (r Test) cmpTOMLArrays(want []interface{}, have interface{}) Test { + // Slice can be decoded to []interface{} for an array of primitives, or + // []map[string]interface{} for an array of tables. + // + // TODO: it would be nicer if it could always decode to []interface{}? + haveSlice, ok := have.([]interface{}) + if !ok { + tblArray, ok := have.([]map[string]interface{}) + if !ok { + return r.mismatch("array", want, have) + } + + haveSlice = make([]interface{}, len(tblArray)) + for i := range tblArray { + haveSlice[i] = tblArray[i] + } + } + + if len(want) != len(haveSlice) { + return r.fail("Array lengths differ for key '%s'"+ + " Expected: %[2]v (len=%[4]d)\n"+ + " Your encoder: %[3]v (len=%[5]d)", + r.Key, want, haveSlice, len(want), len(haveSlice)) + } + for i := 0; i < len(want); i++ { + if sub := r.cmpTOML(want[i], haveSlice[i]); sub.Failed() { + return sub + } + } + return r +} + +// reflect.DeepEqual() that deals with NaN != NaN +func deepEqual(want, have interface{}) bool { + var wantF, haveF float64 + switch f := want.(type) { + case float32: + wantF = float64(f) + case float64: + wantF = f + } + switch f := have.(type) { + case float32: + haveF = float64(f) + case float64: + haveF = f + } + if math.IsNaN(wantF) && math.IsNaN(haveF) { + return true + } + + return reflect.DeepEqual(want, have) +} + +func isTomlValue(v interface{}) bool { + switch v.(type) { + case map[string]interface{}, []interface{}: + return false + } + return true +} diff --git a/toml_test.go b/toml_test.go index a0d37c0b..374aeb96 100644 --- a/toml_test.go +++ b/toml_test.go @@ -11,8 +11,8 @@ import ( "testing" "github.com/BurntSushi/toml" - tomltest "github.com/BurntSushi/toml-test" "github.com/BurntSushi/toml/internal/tag" + tomltest "github.com/BurntSushi/toml/internal/toml-test" ) // Test if the error message matches what we want for invalid tests. Every slice