Skip to content

Commit

Permalink
Merge pull request #460 from epage/compliance
Browse files Browse the repository at this point in the history
fix(parser): Allow appending to dotted table
  • Loading branch information
epage authored Jan 18, 2023
2 parents 7f16c18 + 134560f commit 44f0eaa
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/toml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ serde_spanned = { version = "0.5.0", path = "../serde_spanned", features = ["ser
[dev-dependencies]
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
toml-test-harness = "0.4.2"
toml-test-harness = "0.4.3"
snapbox = "0.4.3"

[[test]]
Expand Down
14 changes: 10 additions & 4 deletions crates/toml/tests/decoder_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ fn main() {
let mut harness = toml_test_harness::DecoderHarness::new(decoder);
harness
.ignore([
"invalid/integer/positive-hex.toml",
"invalid/integer/positive-bin.toml",
"invalid/control/comment-del.toml",
"invalid/control/comment-cr.toml",
"valid/string/escape-esc.toml",
"invalid/control/comment-del.toml",
"invalid/datetime/hour-over.toml",
"invalid/integer/positive-bin.toml",
"invalid/integer/positive-hex.toml",
"valid/inline-table/newline.toml",
"valid/spec/float-0.toml",
"valid/spec/table-9.toml",
// Unreleased
"valid/string/escape-esc.toml",
"valid/string/hex-escape.toml",
"valid/datetime/no-seconds.toml",
])
.unwrap();
harness.test();
Expand Down
2 changes: 2 additions & 0 deletions crates/toml/tests/encoder_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fn main() {
.ignore([
"valid/array/mixed-string-table.toml",
"valid/inline-table/nest.toml",
"valid/spec/float-0.toml",
"valid/spec/array-0.toml",
])
.unwrap();
harness.test();
Expand Down
4 changes: 2 additions & 2 deletions crates/toml_edit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ serde_spanned = { version = "0.5.0", path = "../serde_spanned", features = ["ser

[dev-dependencies]
serde_json = "1.0.91"
toml-test-harness = "0.4.2"
toml-test-data = "1.2.0"
toml-test-harness = "0.4.3"
toml-test-data = "1.3.0"
libtest-mimic = "0.6.0"
snapbox = { version = "0.4.3", features = ["harness"] }

Expand Down
6 changes: 0 additions & 6 deletions crates/toml_edit/src/parser/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ impl ParseState {
// Since tables cannot be defined more than once, redefining such tables using a
// [table] header is not allowed. Likewise, using dotted keys to redefine tables
// already defined in [table] form is not allowed.
if sweet_child_of_mine.is_dotted() && !dotted {
return Err(CustomError::DuplicateKey {
key: key.get().into(),
table: None,
});
}
if dotted && !sweet_child_of_mine.is_implicit() {
return Err(CustomError::DuplicateKey {
key: key.get().into(),
Expand Down
11 changes: 10 additions & 1 deletion crates/toml_edit/tests/decoder_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ mod decoder;
fn main() {
let decoder = decoder::Decoder;
let mut harness = toml_test_harness::DecoderHarness::new(decoder);
harness.ignore(["valid/string/escape-esc.toml"]).unwrap();
harness
.ignore([
"valid/spec/float-0.toml",
// Unreleased
"valid/string/escape-esc.toml",
"valid/string/hex-escape.toml",
"valid/datetime/no-seconds.toml",
"valid/inline-table/newline.toml",
])
.unwrap();
harness.test();
}
11 changes: 10 additions & 1 deletion crates/toml_edit/tests/easy_decoder_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ mod easy_decoder;
fn main() {
let decoder = easy_decoder::Decoder;
let mut harness = toml_test_harness::DecoderHarness::new(decoder);
harness.ignore(["valid/string/escape-esc.toml"]).unwrap();
harness
.ignore([
"valid/spec/float-0.toml",
// Unreleased
"valid/string/escape-esc.toml",
"valid/string/hex-escape.toml",
"valid/datetime/no-seconds.toml",
"valid/inline-table/newline.toml",
])
.unwrap();
harness.test();
}

Expand Down
3 changes: 2 additions & 1 deletion crates/toml_edit/tests/easy_encoder_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ mod easy_encoder;
fn main() {
let encoder = easy_encoder::Encoder;
let decoder = easy_decoder::Decoder;
let harness = toml_test_harness::EncoderHarness::new(encoder, decoder);
let mut harness = toml_test_harness::EncoderHarness::new(encoder, decoder);
harness.ignore(["valid/spec/float-0.toml"]).unwrap();
harness.test();
}

Expand Down
3 changes: 2 additions & 1 deletion crates/toml_edit/tests/encoder_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod encoder;
fn main() {
let encoder = encoder::Encoder;
let decoder = decoder::Decoder;
let harness = toml_test_harness::EncoderHarness::new(encoder, decoder);
let mut harness = toml_test_harness::EncoderHarness::new(encoder, decoder);
harness.ignore(["valid/spec/float-0.toml"]).unwrap();
harness.test();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid utf-8 sequence of 1 bytes from index 66
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid utf-8 sequence of 1 bytes from index 66
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid utf-8 sequence of 1 bytes from index 64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TOML parse error at line 3, column 1
|
3 | type.edible = false # INVALID
| ^
dotted key `type` attempted to extend non-table type (inline table)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TOML parse error at line 3, column 1
|
3 | type = { edible = false } # INVALID
| ^
duplicate key `type` in table `product`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 7
|
1 | key = # INVALID
| ^
invalid string
expected `"`, `'`
5 changes: 5 additions & 0 deletions crates/toml_edit/tests/fixtures/invalid/spec/keys-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TOML parse error at line 1, column 1
|
1 | = "no key name" # INVALID
| ^
invalid key
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TOML parse error at line 2, column 46
|
2 | str5 = """Here are three quotation marks: """.""" # INVALID
| ^
expected newline, `#`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TOML parse error at line 3, column 48
|
3 | apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID
| ^
expected newline, `#`
6 changes: 6 additions & 0 deletions crates/toml_edit/tests/fixtures/invalid/spec/table-9-0.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 5, column 1
|
5 | [fruit.apple] # INVALID
| ^
invalid table header
duplicate key `apple` in table `fruit`
6 changes: 6 additions & 0 deletions crates/toml_edit/tests/fixtures/invalid/spec/table-9-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 6, column 1
|
6 | [fruit.apple.taste] # INVALID
| ^
invalid table header
duplicate key `taste` in table `fruit.apple`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 20
|
1 | bad-hex-esc-1 = "\x0g"
| ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 20
|
1 | bad-hex-esc-2 = "\xG0"
| ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 20
|
1 | bad-hex-esc-3 = "\x"
| ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 20
|
1 | bad-hex-esc-4 = "\x 50"
| ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 20
|
1 | bad-hex-esc-5 = "\x 50"
| ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOML parse error at line 1, column 20
|
1 | bad-hex-esc-1 = "\x0g"
| ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ TOML parse error at line 4, column 1
4 | [fruit.apple.taste] # INVALID
| ^
invalid table header
duplicate key `apple`
duplicate key `taste` in table `fruit.apple`

0 comments on commit 44f0eaa

Please sign in to comment.