diff options
Diffstat (limited to 'tests/typ/control/if.typ')
| -rw-r--r-- | tests/typ/control/if.typ | 45 |
1 files changed, 45 insertions, 0 deletions
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" {} |
