aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/shell.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/world/shell.lux')
-rw-r--r--stdlib/source/test/lux/world/shell.lux58
1 files changed, 58 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux
new file mode 100644
index 000000000..f98fc6a17
--- /dev/null
+++ b/stdlib/source/test/lux/world/shell.lux
@@ -0,0 +1,58 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ ["." exception (#+ exception:)]]
+ [data
+ [number
+ ["n" nat]
+ ["i" int]]
+ [collection
+ ["." list]]]]
+ {1
+ ["." /]}
+ {[1 #spec]
+ ["$." /]})
+
+(exception: dead)
+
+(def: (simulation [environment command arguments])
+ (-> [/.Environment /.Command (List /.Argument)]
+ (/.Simulation Bit))
+ (structure
+ (def: (on-read dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (do try.monad
+ [to-echo (try.from-maybe (list.head arguments))]
+ (wrap [dead? to-echo]))))
+
+ (def: (on-error dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (exception.return [dead? ""])))
+
+ (def: (on-write message dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success dead?)))
+
+ (def: (on-destroy dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success true)))
+
+ (def: (on-await dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success [true /.normal])))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.with-cover [/.mock /.Simulation]
+ ($/.spec (/.mock (|>> ..simulation #try.Success)
+ false)))))