aboutsummaryrefslogtreecommitdiff
path: root/test/optionals.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-21 22:13:21 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-21 22:13:21 -0500
commitd6de03feb280d179efa07e1727f42955b25d733c (patch)
treedd2ce4b8fe7b46ade6de7e45840b8c6840c4fdf7 /test/optionals.tm
parent76b434a6be6c05d7d3dae5b77ec8fd886fd715d0 (diff)
Fix optional path none checks
Diffstat (limited to 'test/optionals.tm')
-rw-r--r--test/optionals.tm20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/optionals.tm b/test/optionals.tm
index 51a78380..d26a9d46 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -61,6 +61,12 @@ func maybe_c_string(should_i:Bool->CString?)
else
return none
+func maybe_path(should_i:Bool->Path?)
+ if should_i
+ return (./foo)
+ else
+ return none
+
func main()
optional : Int? = 5
assert optional == 5
@@ -214,6 +220,20 @@ func main()
fail("Truthy: $nope")
else say("Falsey: $nope")
+ do
+ say("...")
+ say("Paths:")
+ yep := maybe_path(yes)
+ assert yep == (./foo)
+ nope := maybe_path(no)
+ assert nope == none
+ >> if yep
+ assert yep == (./foo)
+ else fail("Falsey: $yep")
+ >> if nope
+ fail("Truthy: $nope")
+ else say("Falsey: $nope")
+
if yep := maybe_int(yes)
assert yep == 123
else fail("Unreachable")