Skip to content

Invalid roundtrip scenario, outputting invalid tables #799

Open
@epage

Description

@epage
#[test]
fn fuzzed_42537130() {
    let data = r#"
[_.s.K]
[_]
s.0.0=2
[_.s.0.1]
[_.s]
"#;
    let doc = data.parse::<toml_edit::DocumentMut>().unwrap();
    let toml = doc.to_string();
    let doc = toml.parse::<toml_edit::DocumentMut>();
    assert!(
        doc.is_ok(),
        "parse error: {}

data:
```toml
{data}
```

doc.to_string():
```toml
{}
```",
        doc.unwrap_err(),
        toml
    );
    let doc = doc.unwrap();
    assert_eq!(
        doc.to_string(),
        toml,
        "data:
```toml
{data}
```
"
    );
}
---- invalid::fuzzed_42537130 stdout ----
thread 'invalid::fuzzed_42537130' panicked at crates/toml_edit/tests/testsuite/invalid.rs:316:5:
parse error: TOML parse error at line 6, column 1
  |
6 | 0.0=2
  | ^
duplicate key `0`

data:

[_.s.K]
[_]
s.0.0=2
[_.s.0.1]
[_.s]

doc.to_string():

[_.s.K]
[_]
[_.s.0.1]
[_.s]
0.0=2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-editArea: TOML editing APIA-outputArea: Outputting TOMLC-bugCategory: Things not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions