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-value.typ | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/typ/control/if-value.typ (limited to 'tests/typ/control/if-value.typ') diff --git a/tests/typ/control/if-value.typ b/tests/typ/control/if-value.typ new file mode 100644 index 00000000..d7124255 --- /dev/null +++ b/tests/typ/control/if-value.typ @@ -0,0 +1,21 @@ +// Test return value of if expressions. +// Ref: false + +--- +{ + let x = 1 + let y = 2 + let z + + // Returns if branch. + z = if x < y { "ok" } + test(z, "ok") + + // Returns else branch. + z = if x > y { "bad" } else { "ok" } + test(z, "ok") + + // Missing else evaluates to none. + z = if x > y { "bad" } + test(z, none) +} -- cgit v1.2.3