aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test
diff options
context:
space:
mode:
authorEduardo Julian2017-05-20 20:23:32 -0400
committerEduardo Julian2017-05-20 20:23:32 -0400
commitd1171dc59edd34418e1b8b4da432c78cd59a9cb4 (patch)
treec76bd1a825197069ec380ac81b00a447a2c7fbf3 /new-luxc/test
parent8f88e4bf4b380e2f09d046fbef05fca452eae62c (diff)
- Simplified the analytic model of tuples into products, and variants into sums.
Diffstat (limited to 'new-luxc/test')
-rw-r--r--new-luxc/test/test/luxc/analyser/primitive.lux10
-rw-r--r--new-luxc/test/test/luxc/analyser/struct.lux17
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))