From a1c192d175f13cdb3e69b3ca5985d0d5ecf0fe93 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 19 Jul 2021 19:50:14 -0400 Subject: Made the default JS file-system promise-based so it works well on Node. --- stdlib/source/test/lux.lux | 93 +++++++++++++++++++++++++++++++++++++++ stdlib/source/test/lux/ffi.js.lux | 11 +++++ 2 files changed, 104 insertions(+) (limited to 'stdlib/source/test') 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?" -- cgit v1.2.3