diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/collection/array.lux | 71 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool.lux | 21 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool/compiler/arity.lux | 29 |
4 files changed, 89 insertions, 36 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index c200a0316..86ed33be3 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -56,7 +56,7 @@ ["[1][0]" target] ["[1][0]" test] ["[1][0]" time] - ... ["[1][0]" tool] ... TODO: Update & expand tests for this + ["[1][0]" tool] ["[1][0]" type] ["[1][0]" world] ["[1][0]" ffi] @@ -97,7 +97,7 @@ /target.test /test.test /time.test - ... /tool.test + /tool.test /type.test /world.test /ffi.test diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index d9e3f01c2..2eca1688b 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -1,27 +1,28 @@ (.using - [library - [lux "*" - ["_" test {"+" Test}] - [abstract - [monad {"+" do}] - [\\specification - ["$[0]" equivalence] - ["$[0]" monoid] - ["$[0]" mix] - ["$[0]" functor {"+" Injection}]]] - [control - ["[0]" maybe]] - [data - ["[0]" bit] - [collection - ["[0]" list] - ["[0]" set]]] - [math - ["[0]" random {"+" Random}] - [number - ["n" nat]]]]] - [\\library - ["[0]" / {"+" Array}]]) + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}] + [\\specification + ["$[0]" equivalence] + ["$[0]" monoid] + ["$[0]" mix] + ["$[0]" functor {"+" Injection}]]] + [control + ["[0]" maybe]] + [data + ["[0]" bit] + ["[0]" text ("[1]#[0]" equivalence)] + [collection + ["[0]" list] + ["[0]" set]]] + [math + ["[0]" random {"+" Random}] + [number + ["n" nat]]]]] + [\\library + ["[0]" / {"+" Array}]]) (def: injection (Injection Array) @@ -29,7 +30,7 @@ (def: bounded_size (Random Nat) - (# random.monad each (|>> (n.% 100) (n.+ 1)) + (# random.monad each (|>> (n.% 20) ++) random.nat)) (def: structures @@ -54,8 +55,28 @@ base random.nat shift random.nat .let [expected (n.+ base shift)] - the_array (random.array size random.nat)] + the_array (random.array size random.nat) + evens (random.array size (random.only n.even? random.nat))] ($_ _.and + (let [(^open "/#[0]") /.functor + choose (: (-> Nat (Maybe Text)) + (function (_ value) + (if (n.even? value) + {.#Some (# n.decimal encoded value)} + {.#None})))] + (_.cover [/.one] + (case [(|> evens + (/#each (# n.decimal encoded)) + (/.read! 0)) + (/.one choose evens)] + [{.#Some expected} {.#Some actual}] + (text#= expected actual) + + [{.#None} {.#None}] + true + + _ + false))) (_.cover [/.example] (# (maybe.equivalence n.equivalence) = (/.example n.even? the_array) diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index 3a9f547cd..5a7509b99 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -4,17 +4,20 @@ ["_" test {"+" Test}]]] ["[0]" / "_" [compiler - [language - [lux - ["[1][0]" syntax] - [phase - ["[1][0]" analysis] - ["[1][0]" synthesis]]]]]]) + ["[1][0]" arity] + ... [language + ... [lux + ... ["[1][0]" syntax] + ... [phase + ... ["[1][0]" analysis] + ... ["[1][0]" synthesis]]]] + ]]) (def: .public test Test ($_ _.and - /syntax.test - /analysis.test - /synthesis.test + /arity.test + ... /syntax.test + ... /analysis.test + ... /synthesis.test )) diff --git a/stdlib/source/test/lux/tool/compiler/arity.lux b/stdlib/source/test/lux/tool/compiler/arity.lux new file mode 100644 index 000000000..0e9f3f25d --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/arity.lux @@ -0,0 +1,29 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}]] + [data + ["[0]" bit ("[1]#[0]" equivalence)]] + [math + ["[0]" random {"+" Random}] + [number + ["n" nat]]]]] + [\\library + ["[0]" /]]) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Arity]) + (do [! random.monad] + [arity (# ! each (n.% 3) random.nat)] + ($_ _.and + (_.cover [/.nullary?] + (bit#= (n.= 0 arity) (/.nullary? arity))) + (_.cover [/.unary?] + (bit#= (n.= 1 arity) (/.unary? arity))) + (_.cover [/.multiary?] + (bit#= (n.>= 2 arity) (/.multiary? arity))) + )))) |