diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:56:16 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:56:16 -0400 |
| commit | 02930b84f821b22cfd629b64169dc0b5a4b8fe74 (patch) | |
| tree | c3b68dd707ff88baae6304366fec75bdd5e19cc0 /test | |
| parent | 908673c9d95a57e794dc1ee5708ffb511958abb9 (diff) | |
Optionals for threads
Diffstat (limited to 'test')
| -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 5d54b29e..d7ce99c0 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -61,6 +61,12 @@ func maybe_channel(should_i:Bool)->|Int|?: else: return !|Int| +func maybe_thread(should_i:Bool)->Thread?: + if should_i: + return Thread.new(func(): pass) + else: + return !Thread + func main(): >> 5? = 5? : Int? @@ -200,6 +206,19 @@ func main(): fail("Truthy: $nope") else: !! Falsey: $nope + do: + !! ... + !! Threads: + >> yep := maybe_thread(yes) + # No "=" test here because threads use addresses in the text version + >> nope := maybe_thread(no) + = !Thread + >> if yep: >> yep + else: fail("Falsey: $yep") + >> if nope: + fail("Truthy: $nope") + else: !! Falsey: $nope + if yep := maybe_int(yes): >> yep = 123 : Int |
