diff options
Diffstat (limited to 'test/optionals.tm')
| -rw-r--r-- | test/optionals.tm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/optionals.tm b/test/optionals.tm index a721deaa..521bba51 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -49,6 +49,12 @@ func maybe_lambda(should_i:Bool)-> func()?: else: return !func() +func maybe_c_string(should_i:Bool)->CString?: + if should_i: + return ("hi":as_c_string())? + else: + return !CString + func main(): >> 5? = 5? : Int? @@ -162,6 +168,19 @@ func main(): fail("Truthy: $nope") else: !! Falsey: $nope + do: + !! ... + !! C Strings: + >> yep := maybe_c_string(yes) + = CString("hi")? + >> nope := maybe_c_string(no) + = !CString + >> if yep: >> yep + else: fail("Falsey: $yep") + >> if nope: + fail("Truthy: $nope") + else: !! Falsey: $nope + if yep := maybe_int(yes): >> yep = 123 : Int |
