diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/test/test/luxc/analyser/primitive.lux | 10 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/analyser/struct.lux | 17 |
2 files changed, 14 insertions, 13 deletions
diff --git a/new-luxc/test/test/luxc/analyser/primitive.lux b/new-luxc/test/test/luxc/analyser/primitive.lux index e844c194d..6053e2fd7 100644 --- a/new-luxc/test/test/luxc/analyser/primitive.lux +++ b/new-luxc/test/test/luxc/analyser/primitive.lux @@ -48,6 +48,7 @@ false)) )] + ["unit" Unit #~;Unit [] (function [value] @;analyse-unit)] ["bool" Bool #~;Bool %bool% @;analyse-bool] ["nat" Nat #~;Nat %nat% @;analyse-nat] ["int" Int #~;Int %int% @;analyse-int] @@ -57,13 +58,4 @@ ["text" Text #~;Text %text% @;analyse-text] )] ($_ seq - (assert (format "Can analyse unit.") - (|> (@common;with-unknown-type - @;analyse-unit) - (macro;run init-compiler) - (case> (^ (#R;Success [_type (#~;Tuple (list))])) - (Type/= Unit _type) - - _ - false))) <primitives>))) diff --git a/new-luxc/test/test/luxc/analyser/struct.lux b/new-luxc/test/test/luxc/analyser/struct.lux index 869b2b0d1..8bf7957b5 100644 --- a/new-luxc/test/test/luxc/analyser/struct.lux +++ b/new-luxc/test/test/luxc/analyser/struct.lux @@ -11,7 +11,7 @@ [macro #+ Monad<Lux>] test) (luxc ["&" base] - (lang ["~" analysis]) + (lang ["la" analysis]) [analyser] (analyser ["@" struct] ["@;" common])) @@ -21,18 +21,27 @@ &;Analyser (analyser;analyser (:!! []))) +(def: (flatten-tuple analysis) + (-> la;Analysis (List la;Analysis)) + (case analysis + (#la;Product left right) + (#;Cons left (flatten-tuple right)) + + _ + (list analysis))) + (test: "Tuples" [size (|> r;nat (:: @ map (|>. (n.% +10) (n.max +2)))) primitives (r;list size gen-simple-primitive)] ($_ seq (assert "Can analyse tuple." (|> (@common;with-unknown-type - (@;analyse-tuple analyse (L/map product;right primitives))) + (@;analyse-product analyse (L/map product;right primitives))) (macro;run init-compiler) - (case> (#R;Success [_type (#~;Tuple elems)]) + (case> (#R;Success [_type tupleA]) (and (Type/= (type;tuple (L/map product;left primitives)) _type) - (n.= size (list;size elems))) + (n.= size (list;size (flatten-tuple tupleA)))) _ false)) |