diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-01-02 20:29:55 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-01-02 20:29:55 -0500 |
| commit | b025cf269d2e07e179be4a0e34d936862dc640c2 (patch) | |
| tree | 6bcce81829436a08dbe4f0101044c0cd07811525 /test/optionals.tm | |
| parent | 500e4e1bd74b45476c4df0f4f9da72fbada9bb18 (diff) | |
Use `holding` blocks for mutexed data instead of lambdas
Diffstat (limited to 'test/optionals.tm')
| -rw-r--r-- | test/optionals.tm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/optionals.tm b/test/optionals.tm index 13a8dcae..3ef7f28e 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -67,6 +67,12 @@ func maybe_thread(should_i:Bool->Thread?): else: return none +func maybe_mutexed(should_i:Bool->mutexed(Bool)?): + if should_i: + return mutexed no + else: + return none + func main(): >> 5? = 5 : Int? @@ -251,6 +257,20 @@ func main(): fail("Truthy: $nope") else: !! Falsey: $nope + do: + !! ... + !! Mutexed: + >> yep := maybe_mutexed(yes) + # No "=" test here because threads use addresses in the text version + >> nope := maybe_mutexed(no) + = none : mutexed(Bool)? + >> if yep: >> yep + else: fail("Falsey: $yep") + >> if nope: + fail("Truthy: $nope") + else: !! Falsey: $nope + + if yep := maybe_int(yes): >> yep = 123 : Int |
