mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Reproduce 2-def bug
This commit is contained in:
parent
981208f548
commit
1f178d7c1a
1 changed files with 41 additions and 0 deletions
|
@ -683,6 +683,47 @@ mod test_parse {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn two_spaced_def() {
|
||||||
|
let arena = Bump::new();
|
||||||
|
let newlines = bumpalo::vec![in &arena; Newline, Newline];
|
||||||
|
let newline = bumpalo::vec![in &arena; Newline];
|
||||||
|
let def1 = Def::BodyOnly(
|
||||||
|
Located::new(1, 1, 0, 1, Identifier("x")),
|
||||||
|
arena.alloc(Located::new(1, 1, 4, 5, Int("5"))),
|
||||||
|
);
|
||||||
|
let def2 = Def::BodyOnly(
|
||||||
|
Located::new(2, 2, 0, 1, Identifier("y")),
|
||||||
|
arena.alloc(Located::new(2, 2, 4, 5, Int("6"))),
|
||||||
|
);
|
||||||
|
// NOTE: The first def always gets reordered to the end (because it
|
||||||
|
// gets added by .push(), since that's more efficient and since
|
||||||
|
// canonicalization is going to re-sort these all anyway.)
|
||||||
|
let defs = bumpalo::vec![in &arena;
|
||||||
|
(newline.into_bump_slice(), def2),
|
||||||
|
(Vec::new_in(&arena).into_bump_slice(), def1)
|
||||||
|
];
|
||||||
|
let ret = Expr::SpaceBefore(arena.alloc(Int("42")), newlines.into_bump_slice());
|
||||||
|
let loc_ret = Located::new(4, 4, 0, 2, ret);
|
||||||
|
let reset_indentation = bumpalo::vec![in &arena; LineComment(" reset indentation")];
|
||||||
|
let expected = Expr::SpaceBefore(
|
||||||
|
arena.alloc(Defs(arena.alloc((defs, loc_ret)))),
|
||||||
|
reset_indentation.into_bump_slice(),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_parses_to(
|
||||||
|
indoc!(
|
||||||
|
r#"# reset indentation
|
||||||
|
x = 5
|
||||||
|
y = 6
|
||||||
|
|
||||||
|
42
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
expected,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO test hex/oct/binary parsing
|
// TODO test hex/oct/binary parsing
|
||||||
//
|
//
|
||||||
// TODO test for \t \r and \n in string literals *outside* unicode escape sequence!
|
// TODO test for \t \r and \n in string literals *outside* unicode escape sequence!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue