diff options
Diffstat (limited to 'stdlib/test')
-rw-r--r-- | stdlib/test/test/lux/data/ident.lux | 19 | ||||
-rw-r--r-- | stdlib/test/test/lux/type.lux | 34 |
2 files changed, 37 insertions, 16 deletions
diff --git a/stdlib/test/test/lux/data/ident.lux b/stdlib/test/test/lux/data/ident.lux index 6c435686f..14adc5371 100644 --- a/stdlib/test/test/lux/data/ident.lux +++ b/stdlib/test/test/lux/data/ident.lux @@ -8,23 +8,28 @@ (lux (codata [io]) (control monad) (data ["&" ident] - [text "Text/" Eq<Text>]) + [text "Text/" Eq<Text>] + text/format) (math ["R" random]) pipe) lux/test) +(def: (gen-part size) + (-> Nat (R;Random Text)) + (|> (R;text size) (R;filter (. not (text;contains? ";"))))) + (test: "Idents" [## First Ident sizeM1 (|> R;nat (:: @ map (n.% +100))) - sizeN1 (|> R;nat (:: @ map (n.% +100))) - module1 (R;text sizeM1) - name1 (R;text sizeN1) + sizeN1 (|> R;nat (:: @ map (|>. (n.% +100) (n.max +1)))) + module1 (gen-part sizeM1) + name1 (gen-part sizeN1) #let [ident1 [module1 name1]] ## Second Ident sizeM2 (|> R;nat (:: @ map (n.% +100))) - sizeN2 (|> R;nat (:: @ map (n.% +100))) - module2 (R;text sizeM2) - name2 (R;text sizeN2) + sizeN2 (|> R;nat (:: @ map (|>. (n.% +100) (n.max +1)))) + module2 (gen-part sizeM2) + name2 (gen-part sizeN2) #let [ident2 [module2 name2]] #let [(^open "&/") &;Eq<Ident> (^open "&/") &;Codec<Text,Ident>]] diff --git a/stdlib/test/test/lux/type.lux b/stdlib/test/test/lux/type.lux index 0e203f376..1f33db816 100644 --- a/stdlib/test/test/lux/type.lux +++ b/stdlib/test/test/lux/type.lux @@ -85,19 +85,27 @@ (test: "Type construction [structs]" [size (|> R;nat (:: @ map (n.% +3))) - members (seqM @ (list;repeat size gen-type)) + members (|> gen-type + (R;filter (lambda [type] + (case type + (^or (#;SumT _) (#;ProdT _)) + false + + _ + true))) + (list;repeat size) + (seqM @)) #let [(^open "&/") &;Eq<Type> (^open "L/") (list;Eq<List> &;Eq<Type>)]] (let% [<struct-tests> (do-template [<desc> <ctor> <dtor> <unit>] [(assert (format "Can build and tear-down " <desc> " types.") (let [flat (|> members <ctor> <dtor>)] - (or (n.= (list;size members) (list;size flat)) - (and (n.= +0 (list;size members)) - (n.= +1 (list;size flat)) - (|> flat list;head (default (undefined)) (&/= <unit>))))))] + (or (L/= members flat) + (and (L/= (list) members) + (L/= (list <unit>) flat)))))] - ["variant" &;variant &;flatten-variant #;VoidT] - ["tuple" &;tuple &;flatten-tuple #;UnitT] + ["variant" &;variant &;flatten-variant Void] + ["tuple" &;tuple &;flatten-tuple Unit] )] ($_ seq <struct-tests> @@ -106,13 +114,21 @@ (test: "Type construction [parameterized]" [size (|> R;nat (:: @ map (n.% +3))) members (seqM @ (list;repeat size gen-type)) - extra gen-type + extra (|> gen-type + (R;filter (lambda [type] + (case type + (^or (#;LambdaT _) (#;ProdT _)) + false + + _ + true)))) #let [(^open "&/") &;Eq<Type> (^open "L/") (list;Eq<List> &;Eq<Type>)]] ($_ seq (assert "Can build and tear-down function types." (let [[inputs output] (|> (&;function members extra) &;flatten-function)] - (n.= (list;size members) (list;size inputs)))) + (and (L/= members inputs) + (&/= extra output)))) (assert "Can build and tear-down application types." (let [[tfunc tparams] (|> members (&;application extra) &;flatten-application)] |