diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-05-09 18:59:23 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-05-09 18:59:23 +0000 |
commit | e425895a315d65ff9ca1e2d7911c2fd21d49fe5e (patch) | |
tree | 7622287d299dbf3edad7679841a59ac47348f1f5 /tests | |
parent | 0f547edbd76814f7a8299f5e1647cd0816276ba8 (diff) |
Fix some nasty bugs with empty lines in dfns, and with stranding of ⍺ and ⍵.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/chain.apl | 7 | ||||
-rw-r--r-- | tests/demo.apl | 31 |
2 files changed, 35 insertions, 3 deletions
diff --git a/tests/chain.apl b/tests/chain.apl index f6ab04b..aeeab52 100644 --- a/tests/chain.apl +++ b/tests/chain.apl @@ -1,8 +1,9 @@ worker←{ - msg←{1}⍇0 - ⎕←'Worker id ',(⍕⎕self),' got message: ',(⍕msg),' forwarding to ',⍕⍵ + msg←1⍨⍇0 ⍵≡⍬: ⎕←'DONE' + ⎕←'Worker id ',(⍕⎕self),' got message: ',(⍕msg) + ⎕←'Forwarding from ',(⍕⎕self), ' to ',⍕⍵ msg⍈⍵ } -last←worker&⍣100⊢⍬ +last←worker&⍣10⊢⍬ 'Hello there'⍈last diff --git a/tests/demo.apl b/tests/demo.apl new file mode 100644 index 0000000..7a6ddca --- /dev/null +++ b/tests/demo.apl @@ -0,0 +1,31 @@ +⍝ The following demonstrates message passing between an 'iota sever', +⍝ and a client (the user of the iota function). The client always initiates +⍝ communication, and the server must be running, but the client should not +⍝ be able to notice a difference between monadic ⍳ and the iota function, +⍝ even though one does the computation in a different thread. + +iotaServer←{ + msg←1⍨⍇0 + msg≡'stop': ⎕←'Bye bye from indexer' + (from num)←msg + _←(⍳num)⍈from + ∇⍵ +} + +id←0 ⍝ this is an invalid thread id, so it is a sane starting point + +start←{ + id=0: iotaServer&⍬ + id +} + +stop←{ + 'stop'⍈id +} + +iota←{ + ⍝ Sending messages to a nonexisting thread throws a domain error (11) + 11::'Sorry, the iota server is not running' + _←(⎕self ⍵)⍈id + 1⍨⍇0 +} |