diff options
author | Eduardo Julian | 2020-05-12 22:18:48 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-05-12 22:18:48 -0400 |
commit | 2ebb1cfc9d8705f9b5812d6d26788c8d3b70b5c8 (patch) | |
tree | 73399c6a47c825b8324767737fd0d3d6f3a11d3e /stdlib/source/test | |
parent | f605537d91450b347ce70eb2c5edff9674e72044 (diff) |
Now logging to a data-structure and only printing in the end.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/control.lux | 10 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/concatenative.lux | 87 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/concurrency/frp.lux | 2 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/concurrency/process.lux | 46 |
4 files changed, 137 insertions, 8 deletions
diff --git a/stdlib/source/test/lux/control.lux b/stdlib/source/test/lux/control.lux index e90ab54f1..b393e1325 100644 --- a/stdlib/source/test/lux/control.lux +++ b/stdlib/source/test/lux/control.lux @@ -17,10 +17,11 @@ ["#." thread] ["#." writer] [concurrency + ["#." actor] ["#." atom] - ["#." promise] ["#." frp] - ["#." actor] + ["#." process] + ["#." promise] ["#." stm]] ["#." parser #_ ["#/." text] @@ -34,10 +35,11 @@ (def: concurrency Test ($_ _.and + /actor.test /atom.test - /promise.test /frp.test - /actor.test + /process.test + /promise.test /stm.test )) diff --git a/stdlib/source/test/lux/control/concatenative.lux b/stdlib/source/test/lux/control/concatenative.lux index 6701916fc..52cd5d214 100644 --- a/stdlib/source/test/lux/control/concatenative.lux +++ b/stdlib/source/test/lux/control/concatenative.lux @@ -146,11 +146,94 @@ |inc| (/.apply/1 inc) |test| (/.apply/1 (|>> (n.- start) (n.< distance)))]] ($_ _.and - (_.cover [/.call] + (_.cover [/.call /.apply/1] (n.= (inc sample) (||> (/.push sample) (/.push (/.apply/1 inc)) /.call))) + (_.cover [/.apply/2] + (n.= (n.+ sample sample) + (||> (/.push sample) + (/.push sample) + (/.push (/.apply/2 n.+)) + /.call))) + (_.cover [/.apply/3] + (n.= ($_ n.+ sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push (/.apply/3 (function (_ i0 i1 i2) + ($_ n.+ i0 i1 i2)))) + /.call))) + (_.cover [/.apply/4] + (n.= ($_ n.+ sample sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push (/.apply/4 (function (_ i0 i1 i2 i3) + ($_ n.+ i0 i1 i2 i3)))) + /.call))) + (_.cover [/.apply/5] + (n.= ($_ n.+ sample sample sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push (/.apply/5 (function (_ i0 i1 i2 i3 i4) + ($_ n.+ i0 i1 i2 i3 i4)))) + /.call))) + (_.cover [/.apply/6] + (n.= ($_ n.+ sample sample sample sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push (/.apply/6 (function (_ i0 i1 i2 i3 i4 i5) + ($_ n.+ i0 i1 i2 i3 i4 i5)))) + /.call))) + (_.cover [/.apply/7] + (n.= ($_ n.+ sample sample sample sample sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push (/.apply/7 (function (_ i0 i1 i2 i3 i4 i5 i6) + ($_ n.+ i0 i1 i2 i3 i4 i5 i6)))) + /.call))) + (_.cover [/.apply/8] + (n.= ($_ n.+ sample sample sample sample sample sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push (/.apply/8 (function (_ i0 i1 i2 i3 i4 i5 i6 i7) + ($_ n.+ i0 i1 i2 i3 i4 i5 i6 i7)))) + /.call))) + (_.cover [/.apply] + (n.= ($_ n.+ sample sample sample sample sample sample sample sample sample) + (||> (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push sample) + (/.push ((/.apply 9) (function (_ i0 i1 i2 i3 i4 i5 i6 i7 i8) + ($_ n.+ i0 i1 i2 i3 i4 i5 i6 i7 i8)))) + /.call))) (_.cover [/.if] (n.= (if choice (inc sample) @@ -219,7 +302,7 @@ Test (do random.monad [sample random.nat] - (_.cover [/.word:] + (_.cover [/.word: /.=> /.||>] (n.= (n.* sample sample) (||> (/.push sample) ..square))))) diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index f7f7427b6..8752a195f 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -13,8 +13,6 @@ ["." exception] ["." io (#+ IO io)]] [data - [text - ["%" format (#+ format)]] [number ["n" nat]] [collection diff --git a/stdlib/source/test/lux/control/concurrency/process.lux b/stdlib/source/test/lux/control/concurrency/process.lux new file mode 100644 index 000000000..165fbad93 --- /dev/null +++ b/stdlib/source/test/lux/control/concurrency/process.lux @@ -0,0 +1,46 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." io]] + [data + [number + ["n" nat] + ["i" int]]] + [time + ["." instant (#+ Instant)] + ["." duration]] + [math + ["." random]]] + {1 + ["." / + [// + ["." atom (#+ Atom)] + ["." promise]]]}) + +(def: #export test + Test + (<| (_.covering /._) + (do random.monad + [dummy random.nat + expected random.nat + delay (|> random.nat (:: @ map (n.% 100)))] + ($_ _.and + (_.cover [/.parallelism] + (n.> 0 /.parallelism)) + (wrap (do promise.monad + [reference-time (promise.future instant.now) + #let [box (atom.atom [reference-time dummy])] + _ (promise.future + (/.schedule delay (do io.monad + [execution-time instant.now] + (atom.write [execution-time expected] box)))) + _ (promise.wait delay) + [execution-time actual] (promise.future (atom.read box))] + (_.claim [/.schedule] + (and (i.>= (.int delay) + (duration.to-millis (instant.span reference-time execution-time))) + (n.= expected actual))))) + )))) |