From cfef667a899339a0fd5b79214d581db6ede10748 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 11 Sep 2024 23:13:41 -0400 Subject: Fix optional integer promotion --- test/optionals.tm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/optionals.tm b/test/optionals.tm index e5ee9bcc..e2cdf9a6 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -19,6 +19,12 @@ func maybe_int(should_i:Bool)->Int?: else: return !Int +func maybe_int64(should_i:Bool)->Int64?: + if should_i: + return 123_i64 + else: + return !Int64 + func maybe_array(should_i:Bool)->[Int]?: if should_i: return [10, 20, 30] @@ -91,6 +97,21 @@ func main(): fail("Truthy: $nope") else: !! Falsey: $nope + do: + !! ... + !! Int64s: + >> yep := maybe_int64(yes) + = 123_i64? + >> nope := maybe_int64(no) + = !Int64 + >> if yep: + >> yep + = 123_i64 + else: fail("Falsey: $yep") + >> if nope: + fail("Truthy: $nope") + else: !! Falsey: $nope + do: !! ... !! Arrays: -- cgit v1.2.3