diff --git a/src/parse/tests.rs b/src/parse/tests.rs index c87d43f74..8d52c24b5 100644 --- a/src/parse/tests.rs +++ b/src/parse/tests.rs @@ -186,21 +186,6 @@ macro_rules! Block { }; } -macro_rules! Let { - (@$pat:expr $(=> $expr:expr)?) => {{ - #[allow(unused)] - let mut expr = None; - $(expr = Some(Box::new(into!($expr)));)? - Expr::Let(ExprLet { - pat: into!($pat).map(|s: &str| Ident(s.into())), - expr - }) - }}; - ($($tts:tt)*) => { - Node::Expr(Let!(@$($tts)*)) - }; -} - #[test] fn test_parse_raw() { // Basic, mostly tested in tokenizer and resolver. @@ -345,26 +330,3 @@ fn test_parse_values() { nodes: [], errors: [S(1..3, "expected expression, found invalid token")]); } - -#[test] -fn test_parse_let_bindings() { - // Basic let. - t!("#let x;" Let!("x")); - t!("#let _y=1;" Let!("_y" => Int(1))); - - // Followed by text. - t!("#let x = 1\n+\n2;\nHi there" - Let!("x" => Binary(Int(1), Add, Int(2))), - Space, Text("Hi"), Space, Text("there")); - - // Missing semicolon. - t!("#let x = a\nHi" - nodes: [Let!("x" => Id("a"))], - errors: [S(11..13, "unexpected identifier"), - S(13..13, "expected semicolon")]); - - // Missing identifier. - t!("#let 1;" - nodes: [], - errors: [S(5..6, "expected identifier, found integer")]) -} diff --git a/tests/ref/lang/let.png b/tests/ref/lang/let.png new file mode 100644 index 000000000..be9d8397f Binary files /dev/null and b/tests/ref/lang/let.png differ diff --git a/tests/typ/lang/let.typ b/tests/typ/lang/let.typ new file mode 100644 index 000000000..c7bba7478 --- /dev/null +++ b/tests/typ/lang/let.typ @@ -0,0 +1,20 @@ +// Automatically initialized with `none`. +#let x; +{(x,)} + +// Can start with underscore. +#let _y=1; +{_y} + +// Multiline. +#let z = "world" + + " 🌏"; Hello, {z}! + +// Error: 1:6-1:7 expected identifier, found integer +#let 1; + +// Error: 4:1-4:3 unexpected identifier +// Error: 3:4-3:9 unexpected identifier +// Error: 3:1-3:1 expected semicolon +#let x = "" +Hi there diff --git a/tests/typeset.rs b/tests/typeset.rs index 3eaca6edf..980e3a6c3 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -204,14 +204,14 @@ fn test_part(i: usize, src: &str, env: &SharedEnv) -> (bool, Vec) { for diag in &diags { if !ref_diags.contains(diag) { - print!(" Unexpected | "); + print!(" Not annotated | "); print_diag(diag, &map); } } for diag in &ref_diags { if !diags.contains(diag) { - print!(" Missing | "); + print!(" Not emitted | "); print_diag(diag, &map); } }