aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-11 12:50:46 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-11 12:50:46 -0400
commit908673c9d95a57e794dc1ee5708ffb511958abb9 (patch)
tree0e72884a44e0ce3b9ee2ff15f3c1a54b107af865 /test
parent30d39378c721aa6506c5aa038f6da9bf98cb1527 (diff)
Optional channels (plus fixed some channel bugs)
Diffstat (limited to 'test')
-rw-r--r--test/optionals.tm19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/optionals.tm b/test/optionals.tm
index 521bba51..5d54b29e 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -55,6 +55,12 @@ func maybe_c_string(should_i:Bool)->CString?:
else:
return !CString
+func maybe_channel(should_i:Bool)->|Int|?:
+ if should_i:
+ return |:Int|?
+ else:
+ return !|Int|
+
func main():
>> 5?
= 5? : Int?
@@ -181,6 +187,19 @@ func main():
fail("Truthy: $nope")
else: !! Falsey: $nope
+ do:
+ !! ...
+ !! Channels:
+ >> yep := maybe_channel(yes)
+ # No "=" test here because channels use addresses in the text version
+ >> nope := maybe_channel(no)
+ = !|:Int|
+ >> if yep: >> yep
+ else: fail("Falsey: $yep")
+ >> if nope:
+ fail("Truthy: $nope")
+ else: !! Falsey: $nope
+
if yep := maybe_int(yes):
>> yep
= 123 : Int