aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2021-07-19 19:50:14 -0400
committerEduardo Julian2021-07-19 19:50:14 -0400
commita1c192d175f13cdb3e69b3ca5985d0d5ecf0fe93 (patch)
tree29d2cd841283ed1ada5a6d3199ce7617c9514c0f /stdlib/source/test
parenta40f40f230e6312ae432f06e7f73aa5945d8fa49 (diff)
Made the default JS file-system promise-based so it works well on Node.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux.lux93
-rw-r--r--stdlib/source/test/lux/ffi.js.lux11
2 files changed, 104 insertions, 0 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index dffa24069..e7ad9d03c 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -619,6 +619,98 @@
(text\= static_char)))
)))
+(type: Small
+ {#small_left Nat
+ #small_right Text})
+
+(type: Big
+ {#big_left Nat
+ #big_right Small})
+
+(def: for_slot
+ Test
+ (do random.monad
+ [start/s random.nat
+ start/b random.nat
+ shift/s random.nat
+ shift/b random.nat
+ text (random.ascii/lower 1)
+ #let [expected/s (n.+ shift/s start/s)
+ expected/b (n.+ shift/b start/b)
+
+ sample {#big_left start/b
+ #big_right {#small_left start/s
+ #small_right text}}]]
+ ($_ _.and
+ (_.cover [/.get@]
+ (and (and (|> sample
+ (/.get@ #big_left)
+ (is? start/b))
+ (|> sample
+ ((/.get@ #big_left))
+ (is? start/b)))
+ (and (|> sample
+ (/.get@ [#big_right #small_left])
+ (is? start/s))
+ (|> sample
+ ((/.get@ [#big_right #small_left]))
+ (is? start/s)))))
+ (_.cover [/.set@]
+ (and (and (|> sample
+ (/.set@ #big_left shift/b)
+ (/.get@ #big_left)
+ (is? shift/b))
+ (|> sample
+ ((/.set@ #big_left shift/b))
+ (/.get@ #big_left)
+ (is? shift/b))
+ (|> sample
+ ((/.set@ #big_left) shift/b)
+ (/.get@ #big_left)
+ (is? shift/b)))
+ (and (|> sample
+ (/.set@ [#big_right #small_left] shift/s)
+ (/.get@ [#big_right #small_left])
+ (is? shift/s))
+ (|> sample
+ ((/.set@ [#big_right #small_left] shift/s))
+ (/.get@ [#big_right #small_left])
+ (is? shift/s))
+ (|> sample
+ ((/.set@ [#big_right #small_left]) shift/s)
+ (/.get@ [#big_right #small_left])
+ (is? shift/s)))))
+ (_.cover [/.update@]
+ (and (and (|> sample
+ (/.update@ #big_left (n.+ shift/b))
+ (/.get@ #big_left)
+ (n.= expected/b))
+ (|> sample
+ ((/.update@ #big_left (n.+ shift/b)))
+ (/.get@ #big_left)
+ (n.= expected/b))
+ (|> sample
+ ((: (-> (-> Nat Nat) (-> Big Big))
+ (/.update@ #big_left))
+ (n.+ shift/b))
+ (/.get@ #big_left)
+ (n.= expected/b)))
+ (and (|> sample
+ (/.update@ [#big_right #small_left] (n.+ shift/s))
+ (/.get@ [#big_right #small_left])
+ (n.= expected/s))
+ (|> sample
+ ((/.update@ [#big_right #small_left] (n.+ shift/s)))
+ (/.get@ [#big_right #small_left])
+ (n.= expected/s))
+ (|> sample
+ ((: (-> (-> Nat Nat) (-> Big Big))
+ (/.update@ [#big_right #small_left]))
+ (n.+ shift/s))
+ (/.get@ [#big_right #small_left])
+ (n.= expected/s)))))
+ )))
+
(def: test
Test
(<| (_.covering /._)
@@ -645,6 +737,7 @@
..for_function
..for_template
..for_static
+ ..for_slot
..sub_tests
)))
diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux
index 70ca96929..6e8a38684 100644
--- a/stdlib/source/test/lux/ffi.js.lux
+++ b/stdlib/source/test/lux/ffi.js.lux
@@ -82,6 +82,17 @@
[/.Undefined]
))
))
+ (_.cover [/.null]
+ (exec
+ (: Nat (/.null []))
+ (: Text (/.null []))
+ (: (All [a] (-> a a)) (/.null []))
+ true))
+ (_.cover [/.null?]
+ (and (/.null? (/.null []))
+ (not (/.null? 0))
+ (not (/.null? "0"))
+ (not (/.null? (|>>)))))
(_.cover [/.constant]
(|> (/.constant /.Function [parseFloat])
"js object null?"