From 05727bfc3a9cfd45a8e2028dfd0806f7a8f88015 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 20 Feb 2021 17:53:40 +0100 Subject: =?UTF-8?q?Reorganize=20tests=20=F0=9F=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/typ/control/if.typ | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/typ/control/if.typ (limited to 'tests/typ/control/if.typ') diff --git a/tests/typ/control/if.typ b/tests/typ/control/if.typ new file mode 100644 index 00000000..4ed6b649 --- /dev/null +++ b/tests/typ/control/if.typ @@ -0,0 +1,45 @@ +// Test if-else expressions. + +--- +// Test condition evaluation. +#if 1 < 2 [ + Ok. +] + +#if true == false [ + Bad, but we {dont-care}! +] + +--- +// Brace in condition. +#if {true} [ + Ok. +] + +// Multi-line condition with parens. +#if ( + 1 + 1 + == 1 +) { + nope +} #else { + "Ok." +} + +// Multiline. +#if false [ + Bad. +] #else { + let pt = "." + "Ok" + pt +} + +--- +// Condition must be boolean. +// If it isn't, neither branch is evaluated. +// Error: 5-14 expected boolean, found string +#if "a" + "b" { nope } #else { nope } + +// Make sure that we don't complain twice. +// Error: 5-12 cannot add integer and string +#if 1 + "2" {} -- cgit v1.2.3