diff options
Diffstat (limited to 'stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux')
-rw-r--r-- | stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux index 08344f23e..ad2233b26 100644 --- a/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux @@ -14,6 +14,8 @@ ["." product] ["." maybe] ["." text] + [number + ["n" nat]] [collection ["." list ("#@." functor)] ["." set]]] @@ -48,13 +50,13 @@ (def: (check-sum' tag size variant) (-> Tag Nat (Variant Analysis) Bit) - (let [expected//right? (n/= (dec size) tag) + (let [expected//right? (n.= (dec size) tag) expected//lefts (if expected//right? (dec tag) tag) actual//right? (get@ #////analysis.right? variant) actual//lefts (get@ #////analysis.lefts variant)] - (and (n/= expected//lefts + (and (n.= expected//lefts actual//lefts) (bit@= expected//right? actual//right?)))) @@ -93,7 +95,7 @@ (|>> (case> (^ (////analysis.tuple elems)) (|> elems list.size - (n/= size)) + (n.= size)) _ false))) @@ -112,10 +114,10 @@ (def: sum (do r.monad - [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) - choice (|> r.nat (:: @ map (n/% size))) + [size (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2)))) + choice (|> r.nat (:: @ map (n.% size))) primitives (r.list size _primitive.primitive) - +choice (|> r.nat (:: @ map (n/% (inc size)))) + +choice (|> r.nat (:: @ map (n.% (inc size)))) [_ +valueC] _primitive.primitive #let [variantT (type.variant (list@map product.left primitives)) [valueT valueC] (maybe.assume (list.nth choice primitives)) @@ -154,7 +156,7 @@ (/.sum _primitive.phase +choice +valueC)) check-succeeds)) (_.test "Can analyse through universal quantification." - (let [check-outcome (if (not (n/= choice +choice)) + (let [check-outcome (if (not (n.= choice +choice)) check-succeeds check-fails)] (|> (//type.with-type (type.univ-q 1 +variantT) @@ -164,9 +166,9 @@ (def: product (do r.monad - [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) + [size (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2)))) primitives (r.list size _primitive.primitive) - choice (|> r.nat (:: @ map (n/% size))) + choice (|> r.nat (:: @ map (n.% size))) [_ +valueC] _primitive.primitive #let [tupleT (type.tuple (list@map product.left primitives)) [singletonT singletonC] (|> primitives (list.nth choice) maybe.assume) @@ -224,10 +226,10 @@ (def: variant (do r.monad - [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) + [size (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2)))) tags (|> (r.set text.hash size (r.unicode 5)) (:: @ map set.to-list)) - choice (|> r.nat (:: @ map (n/% size))) - other-choice (|> r.nat (:: @ map (n/% size)) (r.filter (|>> (n/= choice) not))) + choice (|> r.nat (:: @ map (n.% size))) + other-choice (|> r.nat (:: @ map (n.% size)) (r.filter (|>> (n.= choice) not))) primitives (r.list size _primitive.primitive) module-name (r.unicode 5) type-name (r.unicode 5) @@ -270,12 +272,12 @@ (def: record (do r.monad - [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) + [size (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2)))) tags (|> (r.set text.hash size (r.unicode 5)) (:: @ map set.to-list)) primitives (r.list size _primitive.primitive) module-name (r.unicode 5) type-name (r.unicode 5) - choice (|> r.nat (:: @ map (n/% size))) + choice (|> r.nat (:: @ map (n.% size))) #let [varT (#.Parameter 1) tagsC (list@map (|>> [module-name] code.tag) tags) primitivesT (list@map product.left primitives) |