aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec
diff options
context:
space:
mode:
authorEduardo Julian2020-11-05 22:54:05 -0400
committerEduardo Julian2020-11-05 22:54:05 -0400
commitef78c1f92ab29c4370193591b170535dd9e743f7 (patch)
treee83fd11eb20b4df26f6f5a20bef38af9d2baac8a /stdlib/source/spec
parent11cc4a67001162d689eb827f755424a07b99fccb (diff)
Improved error reporting for syntax macros.
Diffstat (limited to '')
-rw-r--r--stdlib/source/spec/aedifex/repository.lux49
-rw-r--r--stdlib/source/spec/lux/world/console.lux11
2 files changed, 56 insertions, 4 deletions
diff --git a/stdlib/source/spec/aedifex/repository.lux b/stdlib/source/spec/aedifex/repository.lux
new file mode 100644
index 000000000..613bbd407
--- /dev/null
+++ b/stdlib/source/spec/aedifex/repository.lux
@@ -0,0 +1,49 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ [concurrency
+ ["." promise (#+ Promise)]]]
+ [data
+ ["." binary
+ {[0 #test]
+ ["_#" /]}]]
+ [math
+ ["." random]]]
+ {#program
+ ["." /
+ ["/#" // #_
+ ["#." artifact (#+ Artifact)
+ ["#/." extension]]]]}
+ {#test
+ ["_." // #_
+ ["#." artifact]]})
+
+(def: #export (spec valid-identity valid-artifact invalid-identity invalid-artifact subject)
+ (-> /.Identity Artifact /.Identity Artifact (/.Repository Promise) Test)
+ (do random.monad
+ [expected (_binary.random 100)]
+ (wrap ($_ _.and'
+ (do promise.monad
+ [upload!/good (:: subject upload valid-identity valid-artifact //artifact/extension.lux-library expected)
+ download!/good (:: subject download valid-artifact //artifact/extension.lux-library)
+
+ upload!/bad (:: subject upload invalid-identity invalid-artifact //artifact/extension.lux-library expected)
+ download!/bad (:: subject download invalid-artifact //artifact/extension.lux-library)]
+ (_.claim [/.Repository]
+ (and (case [upload!/good download!/good]
+ [(#try.Success _) (#try.Success actual)]
+ (:: binary.equivalence = expected actual)
+
+ _
+ false)
+ (case [upload!/bad download!/bad]
+ [(#try.Failure _) (#try.Failure _)]
+ true
+
+ _
+ false))))
+ ))))
diff --git a/stdlib/source/spec/lux/world/console.lux b/stdlib/source/spec/lux/world/console.lux
index b9e1c0720..93d2c7417 100644
--- a/stdlib/source/spec/lux/world/console.lux
+++ b/stdlib/source/spec/lux/world/console.lux
@@ -4,6 +4,7 @@
[abstract
[monad (#+ do)]]
[control
+ [io (#+ IO)]
["." try]
[security
["!" capability]]
@@ -15,12 +16,13 @@
["." /]})
(def: #export (spec console)
- (-> (/.Console Promise) Test)
+ (-> (IO (/.Console Promise)) Test)
(<| (_.with-cover [/.Console])
(do {! random.monad}
[message (random.ascii/alpha 10)]
(wrap (do promise.monad
- [?read (!.use (:: console read) [])
+ [console (promise.future console)
+ ?read (!.use (:: console read) [])
?read-line (!.use (:: console read-line) [])
?write (!.use (:: console write) [message])
?close/good (!.use (:: console close) [])
@@ -30,7 +32,7 @@
(case [?read ?read-line]
[(#try.Success _) (#try.Success _)]
true
-
+
_
false))
(_.claim [/.Can-Write]
@@ -46,4 +48,5 @@
true
_
- false))))))))
+ false))
+ ))))))