From 469d78d610085044845f0fba462f1d8170b62cd4 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 14 Jan 2021 17:41:13 +0100 Subject: [PATCH] =?UTF-8?q?Move=20let-binding=20tests=20to=20integration?= =?UTF-8?q?=20=F0=9F=9A=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parse/tests.rs | 38 -------------------------------------- tests/ref/lang/let.png | Bin 0 -> 1493 bytes tests/typ/lang/let.typ | 20 ++++++++++++++++++++ tests/typeset.rs | 4 ++-- 4 files changed, 22 insertions(+), 40 deletions(-) create mode 100644 tests/ref/lang/let.png create mode 100644 tests/typ/lang/let.typ 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 0000000000000000000000000000000000000000..be9d8397f036fce28a5776d2dcd95525148f0796 GIT binary patch literal 1493 zcmai!eKgYx9L9faON$wHiP74MyUW?UPhPsD zag4m>HJOl?qLFur$jgWrDaGyn(K+37?mhQ8pYxpOkMDoadA_$?T^!_P)MWqwkjFaO zx&we1_)9L3`eFdMJ=YQdByzB}7>}s2m5G(KN;H%{U3|SiK0IH8rceP|rY^$5sTyk$ zj~0Owj?$?q%5OJ7mFblihq4ssHIl2|=Y_)QvqpY*s&r((Dk)O31tHg}^#4p3D`jty zRP`8v7^?Tcyn!IKF9Bfg&Dyav8}*x1rwPv7(m;$_>dELd%my1~5=|`#Kri(pJ9j*=xO3zg&k($OB{iF;^jX z6s%l9a>5I${;YiozrkkP!E3wbN<$RGOW+Y{UA*{Ob{N}D47xKXF+Hl3nU3QzH@k@^ zL^7P$#XWOj^-yvwa>Zs9`jFnw>$?mYTH|0h_rIa-GILRvA?rWB8l~Ihs*x^8V4aQ- zk5BxNM~=dQw>Bl??JZEM29uiQ8?`_{hS94tFa&#?e1SdCGl#$QFiAF9#`1NXse>b)e`;9AfplG)j@m>H|X_huy)$rk1toz${^A%6ekSja*_B1f4d zM<^>PLEGQtIa=OGA=GjWKImsHCXI^m2Kpyrx{N11R{B+ZYb;iX@L8uTB|DQ+DaE#3 z6fcm-+@g($d2$`YN({vdP|Mv87(h@ewc3k{u&9{FA59TB3zzVE*d2HqLM=E}9gcH1 zybPIf69gHPko8`{Oe+uB--|pD+#YBE7oCAlcQ=3IG>N-i`A!v3K~wX z;UldPgIi^$8F}9^Xo9# zci1zV8jwM~>u4sm&)KT{7LCSDTg&r#V>FX)0if zdBO%Zoj|L=m5w4{jmj~`1Xzh5yGG2Vegq$!`;G@Gyp@{S5l%tT4(E+eX^F~tcbFGV zDu@f;kz{f=SCRZ`-Yuwy_^m#g`>1V9-Nb9|`L$hveh!)JqGiiiu*ZOYX z4O~-q=Q^0YnBB$@983a2yz+t-Qkpe*G;FIz_k<^kGlqErs=K>{V(F~tPM z&)n&_zvoX|2w!Tjkyt+ds4zHTbaBwLM;G_9A1SXU=7;F%$e$_F&zL72wbTe)@XR@{ z@a%)IAl#>MU@)2{?k?7BCYLr1u%Y)WPExGsIFXVce=SpjL{>XESRTb}zyw)jD8$*lUzm=F`uEk0J nV^rS`>`SgQOSth>?Syy7&>`~*MW)F0zyCGX&c&8z{Y%1MX(+Gk literal 0 HcmV?d00001 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); } }