aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world
diff options
context:
space:
mode:
authorEduardo Julian2020-11-05 02:31:55 -0400
committerEduardo Julian2020-11-05 02:31:55 -0400
commit11cc4a67001162d689eb827f755424a07b99fccb (patch)
treea689186bf0bef21056a3ad13e8f06f313a3a6989 /stdlib/source/test/lux/world
parent8ac980fd3b6d2050edc0e631a00028c1e6c28c73 (diff)
Lightweight machinery for agent-oriented programming.
Diffstat (limited to 'stdlib/source/test/lux/world')
-rw-r--r--stdlib/source/test/lux/world/console.lux43
1 files changed, 43 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux
new file mode 100644
index 000000000..d17559cec
--- /dev/null
+++ b/stdlib/source/test/lux/world/console.lux
@@ -0,0 +1,43 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ ["." exception (#+ exception:)]]]
+ {1
+ ["." /]}
+ {[1 #spec]
+ ["$." /]})
+
+(exception: dead)
+
+(def: simulation
+ (/.Simulation Bit)
+ (structure
+ (def: (on-read dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success [dead? (char "a")])))
+
+ (def: (on-read-line dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success [dead? "YOLO"])))
+
+ (def: (on-write message dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success dead?)))
+
+ (def: (on-close dead?)
+ (if dead?
+ (exception.throw ..dead [])
+ (#try.Success true)))))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.with-cover [/.mock /.Simulation]
+ ($/.spec (/.mock ..simulation false)))))