kdl-rs
kdl-rs copied to clipboard
Fix tests
In order,
- Updates the test to pass on main (4ac459a)
- Reverts #49 and the format mangling resulting from it (f820145)
- Adds a new test showing the case in #49 working without #49 (b7fd360)
It might be worthwhile to change how indenting is handled (see e.g. the empty line in the new test), but this is a minimal patch to quickly fix test errors.
cc @cbiffle
FWIW, the all-closing-braces-at-the-left-margin behavior I was seeing (which I'm still seeing on the released package, btw) is from programmatically created documents, not parsed documents. So your test case may be testing something else.
Reproduced in cec5858; something odd is certainly going on.
This fails:
#[test]
fn parse_vs_build() -> miette::Result<()> {
let mut built = build_abc();
let mut parsed: KdlDocument = built.to_string().parse()?;
built.fmt();
parsed.fmt();
assert_eq!(built, parsed);
Ok(())
}
diff
Diff < built / parsed > :
KdlDocument {
< leading: None,
> leading: Some(
> "",
> ),
nodes: [
KdlNode {
< leading: None,
> leading: Some(
> "",
> ),
ty: None,
name: KdlIdentifier {
value: "a",
repr: None,
},
entries: [],
before_children: None,
children: Some(
KdlDocument {
< leading: None,
> leading: Some(
> "\n",
> ),
nodes: [
KdlNode {
< leading: None,
> leading: Some(
> " ",
> ),
ty: None,
name: KdlIdentifier {
value: "b",
repr: None,
},
entries: [],
before_children: None,
children: Some(
KdlDocument {
< leading: None,
> leading: Some(
> "\n",
> ),
nodes: [
KdlNode {
< leading: None,
> leading: Some(
> " ",
> ),
ty: None,
name: KdlIdentifier {
value: "c",
repr: None,
},
entries: [],
before_children: None,
children: Some(
KdlDocument {
< leading: None,
> leading: Some(
> "\n",
> ),
nodes: [],
< trailing: None,
> trailing: Some(
> "\n ",
> ),
},
),
< trailing: None,
> trailing: Some(
> "\n",
> ),
},
],
< trailing: None,
> trailing: Some(
> " ",
> ),
},
),
< trailing: None,
> trailing: Some(
> "\n",
> ),
},
],
< trailing: None,
> trailing: Some(
> "",
> ),
},
),
< trailing: None,
> trailing: Some(
> "\n",
> ),
},
],
< trailing: None,
> trailing: Some(
> "",
> ),
}