diff options
author | Eduardo Julian | 2019-02-12 18:39:05 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-12 18:39:05 -0400 |
commit | 750b4a8c13c7f4392c61bd6c7ebbc0cfed95e70f (patch) | |
tree | 1bbd87c94be6db7ab2057479bdb3fd3dfa34d383 /stdlib/source/test/lux/control/thread.lux | |
parent | 77259cb45d346d66c6feb5b5a5070837780e7bb9 (diff) |
Ported 2 new test modules to the new format.
Diffstat (limited to 'stdlib/source/test/lux/control/thread.lux')
-rw-r--r-- | stdlib/source/test/lux/control/thread.lux | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux index 8f31addbb..61b7524cc 100644 --- a/stdlib/source/test/lux/control/thread.lux +++ b/stdlib/source/test/lux/control/thread.lux @@ -1,21 +1,44 @@ (.module: [lux #* + ["_" test (#+ Test)] [control [monad (#+ do)] - ["/" thread]]]) + {[0 #test] + [/ + [".T" functor (#+ Injection Comparison)] + [".T" apply] + [".T" monad]]}] + [data + [text + format]] + [math + ["r" random]]] + {1 + ["." / (#+ Thread)]}) -(def: _test0_ - Nat - (/.run (do /.monad - [box (/.box 123) - old (/.update (n/* 2) box) - new (/.read box)] - (wrap (n/+ old new))))) +(def: (injection value) + (Injection (All [a !] (Thread ! a))) + (:: /.monad wrap value)) -(def: _test1_ - (All [!] (/.Thread ! Nat)) - (do /.monad - [box (/.box 123) - old (/.update (n/* 2) box) - new (/.read box)] - (wrap (n/+ old new)))) +(def: comparison + (Comparison (All [a !] (Thread ! a))) + (function (_ == left right) + (== (/.run left) (/.run right)))) + +(def: #export test + Test + (do r.monad + [original r.nat + factor r.nat] + (<| (_.context (%name (name-of /.Thread))) + ($_ _.and + (functorT.laws ..injection ..comparison /.functor) + (applyT.laws ..injection ..comparison /.apply) + (monadT.laws ..injection ..comparison /.monad) + (_.test "Can safely do mutation." + (n/= (n/* factor original) + (/.run (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box original) + old (/.update (n/* factor) box)] + (/.read box)))))))))) |