aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/tool/compiler')
-rw-r--r--stdlib/source/test/lux/tool/compiler/default/syntax.lux16
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/case.lux12
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux10
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux6
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux30
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux8
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux26
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux16
8 files changed, 69 insertions, 55 deletions
diff --git a/stdlib/source/test/lux/tool/compiler/default/syntax.lux b/stdlib/source/test/lux/tool/compiler/default/syntax.lux
index 1b9e5c7a4..2b53cbfdb 100644
--- a/stdlib/source/test/lux/tool/compiler/default/syntax.lux
+++ b/stdlib/source/test/lux/tool/compiler/default/syntax.lux
@@ -3,7 +3,9 @@
[abstract/monad (#+ do)]
[data
["%" text/format (#+ format)]
- ["." name]]
+ ["." name]
+ [number
+ ["n" nat]]]
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
@@ -29,7 +31,7 @@
(def: name-part^
(Random Text)
(do r.monad
- [size (|> r.nat (:: @ map (|>> (n/% 20) (n/max 1))))]
+ [size (|> r.nat (:: @ map (|>> (n.% 20) (n.max 1))))]
(r.ascii/lower-alpha size)))
(def: name^
@@ -48,7 +50,7 @@
textual^ (: (Random Code)
($_ r.either
(do r.monad
- [size (|> r.nat (r@map (n/% 20)))]
+ [size (|> r.nat (r@map (n.% 20)))]
(|> (r.ascii/upper-alpha size) (r@map code.text)))
(|> name^ (r@map code.identifier))
(|> name^ (r@map code.tag))))
@@ -59,14 +61,14 @@
(r.rec
(function (_ code^)
(let [multi^ (do r.monad
- [size (|> r.nat (r@map (n/% 3)))]
+ [size (|> r.nat (r@map (n.% 3)))]
(r.list size code^))
composite^ (: (Random Code)
($_ r.either
(|> multi^ (r@map code.form))
(|> multi^ (r@map code.tuple))
(do r.monad
- [size (|> r.nat (r@map (n/% 3)))]
+ [size (|> r.nat (r@map (n.% 3)))]
(|> (r.list size (r.and code^ code^))
(r@map code.record)))))]
($_ r.either
@@ -110,9 +112,9 @@
(def: comment-text^
(Random Text)
- (let [char-gen (|> r.nat (r.filter (|>> (n/= (`` (char (~~ (static text.new-line))))) not)))]
+ (let [char-gen (|> r.nat (r.filter (|>> (n.= (`` (char (~~ (static text.new-line))))) not)))]
(do r.monad
- [size (|> r.nat (r@map (n/% 20)))]
+ [size (|> r.nat (r@map (n.% 20)))]
(r.text char-gen size))))
(def: comment^
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/case.lux
index 30b446bb5..1a74a3cf2 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/case.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/case.lux
@@ -12,6 +12,8 @@
["." product]
["." maybe]
["." text ("#@." equivalence)]
+ [number
+ ["n" nat]]
[collection
["." list ("#@." monad)]
["." set]]]
@@ -116,12 +118,12 @@
($_ r.either
(r@map product.right _primitive.primitive)
(do r.monad
- [choice (|> r.nat (:: @ map (n/% (list.size variant-tags))))
+ [choice (|> r.nat (:: @ map (n.% (list.size variant-tags))))
#let [choiceT (maybe.assume (list.nth choice variant-tags))
choiceC (maybe.assume (list.nth choice primitivesC))]]
(wrap (` ((~ choiceT) (~ choiceC)))))
(do r.monad
- [size (|> r.nat (:: @ map (n/% 3)))
+ [size (|> r.nat (:: @ map (n.% 3)))
elems (r.list size input)]
(wrap (code.tuple elems)))
(r@wrap (code.record (list.zip2 record-tags primitivesC)))
@@ -137,7 +139,7 @@
[module-name (r.unicode 5)
variant-name (r.unicode 5)
record-name (|> (r.unicode 5) (r.filter (|>> (text@= variant-name) not)))
- size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2))))
+ size (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2))))
variant-tags (|> (r.set text.hash size (r.unicode 5)) (:: @ map set.to-list))
record-tags (|> (r.set text.hash size (r.unicode 5)) (:: @ map set.to-list))
primitivesTC (r.list size _primitive.primitive)
@@ -178,7 +180,7 @@
_structure.check-fails)))
(do @
[redundant-patterns (exhaustive-branches false variantTC inputC)
- redundancy-idx (|> r.nat (:: @ map (n/% (list.size redundant-patterns))))
+ redundancy-idx (|> r.nat (:: @ map (n.% (list.size redundant-patterns))))
#let [redundant-branchesC (<| (list@map (branch outputC))
list.concat
(list (list.take redundancy-idx redundant-patterns)
@@ -190,7 +192,7 @@
(do @
[[heterogeneousT heterogeneousC] (r.filter (|>> product.left (check.checks? outputT) not)
_primitive.primitive)
- heterogeneous-idx (|> r.nat (:: @ map (n/% (list.size exhaustive-patterns))))
+ heterogeneous-idx (|> r.nat (:: @ map (n.% (list.size exhaustive-patterns))))
#let [heterogeneous-branchesC (list.concat (list (list.take heterogeneous-idx exhaustive-branchesC)
(list (let [[_pattern _body] (maybe.assume (list.nth heterogeneous-idx exhaustive-branchesC))]
[_pattern heterogeneousC]))
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux
index 7d5046571..721e17b14 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux
@@ -13,6 +13,8 @@
["." maybe]
["." product]
["." text ("#@." equivalence)]
+ [number
+ ["n" nat]]
[collection
["." list ("#@." functor)]]]
["." type]
@@ -38,7 +40,7 @@
(///.run _primitive.state)
(case> (#try.Success applyA)
(let [[funcA argsA] (////analysis.application applyA)]
- (n/= num-args (list.size argsA)))
+ (n.= num-args (list.size argsA)))
(#try.Failure _)
false)))
@@ -74,9 +76,9 @@
(def: apply
(do r.monad
- [full-args (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2))))
- partial-args (|> r.nat (:: @ map (n/% full-args)))
- var-idx (|> r.nat (:: @ map (|>> (n/% full-args) (n/max 1))))
+ [full-args (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2))))
+ partial-args (|> r.nat (:: @ map (n.% full-args)))
+ var-idx (|> r.nat (:: @ map (|>> (n.% full-args) (n.max 1))))
inputsTC (r.list full-args _primitive.primitive)
#let [inputsT (list@map product.left inputsTC)
inputsC (list@map product.right inputsTC)]
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux
index 777fe152f..1c23b1c8a 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux
@@ -9,7 +9,9 @@
pipe
["." try (#+ Try)]]
[data
- ["." text ("#@." equivalence)]]
+ ["." text ("#@." equivalence)]
+ [number
+ ["n" nat]]]
["." type ("#@." equivalence)]
[macro
["." code]]]
@@ -74,7 +76,7 @@
(///.run _primitive.state)
(case> (^ (#try.Success [inferredT (#////analysis.Reference (////reference.local var))]))
(and (type@= expectedT inferredT)
- (n/= 0 var))
+ (n.= 0 var))
_
false)))
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)
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux
index d2d310fa1..13418eba0 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux
@@ -2,7 +2,9 @@
[lux #*
[abstract ["." monad (#+ do)]]
[data
- ["." name]]
+ ["." name]
+ [number
+ ["n" nat]]]
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
@@ -25,7 +27,7 @@
Test
(do r.monad
[maskedA //primitive.primitive
- temp (|> r.nat (:: @ map (n/% 100)))
+ temp (|> r.nat (:: @ map (n.% 100)))
#let [maskA (////analysis.control/case
[maskedA
[[(#////analysis.Bind temp)
@@ -54,7 +56,7 @@
//.phase
(///.run [///bundle.empty ////synthesis.init])
(case> (^ (#try.Success (////synthesis.branch/let [inputS registerS outputS])))
- (and (n/= registerA registerS)
+ (and (n.= registerA registerS)
(//primitive.corresponds? inputA inputS)
(//primitive.corresponds? outputA outputS))
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux
index 368b692e9..db6c38eca 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux
@@ -12,7 +12,7 @@
["." product]
["." maybe]
[number
- ["." nat]]
+ ["n" nat]]
[collection
["." list ("#@." functor fold)]
["dict" dictionary (#+ Dictionary)]
@@ -48,12 +48,12 @@
(def: (pick scope-size)
(-> Nat (Random Nat))
- (|> r.nat (:: r.monad map (n/% scope-size))))
+ (|> r.nat (:: r.monad map (n.% scope-size))))
(def: function-with-environment
(Random [Arity Analysis Variable])
(do r.monad
- [num-locals (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
+ [num-locals (|> r.nat (:: @ map (|>> (n.% 100) (n.max 10))))
#let [indices (list.n/range 0 (dec num-locals))
local-env (list@map (|>> #////reference.Local) indices)
foreign-env (list@map (|>> #////reference.Foreign) indices)]
@@ -64,14 +64,14 @@
resolver (list@fold (function (_ [idx var] resolver)
(dict.put idx var resolver))
(: (Dictionary Nat Variable)
- (dict.new nat.hash))
+ (dict.new n.hash))
(list.enumerate current-env))]
(do @
[nest? r.bit]
(if nest?
(do @
- [num-picks (:: @ map (n/max 1) (pick (inc current-env/size)))
- picks (|> (r.set nat.hash num-picks (pick current-env/size))
+ [num-picks (:: @ map (n.max 1) (pick (inc current-env/size)))
+ picks (|> (r.set n.hash num-picks (pick current-env/size))
(:: @ map set.to-list))
[arity bodyA predictionA] (recur (inc arity)
(list@map (function (_ pick)
@@ -102,10 +102,10 @@
(#////analysis.Function (list) bodyA)
predictionA]))
(do r.monad
- [chosen (|> r.nat (:: @ map (|>> (n/% 100) (n/max 2))))]
+ [chosen (|> r.nat (:: @ map (|>> (n.% 100) (n.max 2))))]
(wrap [arity
(#////analysis.Reference (////reference.local chosen))
- (|> chosen (n/+ (dec arity)) #////reference.Local)])))))
+ (|> chosen (n.+ (dec arity)) #////reference.Local)])))))
(def: abstraction
Test
@@ -119,17 +119,17 @@
//.phase
(///.run [///bundle.empty ////synthesis.init])
(case> (^ (#try.Success (////synthesis.function/abstraction [environment arity output])))
- (and (n/= arity//constant arity)
+ (and (n.= arity//constant arity)
(//primitive.corresponds? prediction//constant output))
_
- (n/= 0 arity//constant))))
+ (n.= 0 arity//constant))))
(_.test "Folded functions provide direct access to environment variables."
(|> function//environment
//.phase
(///.run [///bundle.empty ////synthesis.init])
(case> (^ (#try.Success (////synthesis.function/abstraction [environment arity (#////synthesis.Reference (////reference.variable output))])))
- (and (n/= arity//environment arity)
+ (and (n.= arity//environment arity)
(variable@= prediction//environment output))
_
@@ -139,7 +139,7 @@
//.phase
(///.run [///bundle.empty ////synthesis.init])
(case> (^ (#try.Success (////synthesis.function/abstraction [environment arity (#////synthesis.Reference (////reference.variable output))])))
- (and (n/= arity//local arity)
+ (and (n.= arity//local arity)
(variable@= prediction//local output))
_
@@ -149,7 +149,7 @@
(def: application
Test
(do r.monad
- [arity (|> r.nat (:: @ map (|>> (n/% 10) (n/max 1))))
+ [arity (|> r.nat (:: @ map (|>> (n.% 10) (n.max 1))))
funcA //primitive.primitive
argsA (r.list arity //primitive.primitive)]
($_ _.and
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux
index 76405c771..087756562 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux
@@ -12,6 +12,8 @@
[data
["." bit ("#@." equivalence)]
["." product]
+ [number
+ ["n" nat]]
[collection
["." list]]]]
["." // #_
@@ -29,9 +31,9 @@
(def: variant
Test
(do r.monad
- [size (|> r.nat (:: @ map (|>> (n/% 10) (n/+ 2))))
- tagA (|> r.nat (:: @ map (n/% size)))
- #let [right? (n/= (dec size) tagA)
+ [size (|> r.nat (:: @ map (|>> (n.% 10) (n.+ 2))))
+ tagA (|> r.nat (:: @ map (n.% size)))
+ #let [right? (n.= (dec size) tagA)
lefts (if right?
(dec tagA)
tagA)]
@@ -42,8 +44,8 @@
(///.run [///bundle.empty ////synthesis.init])
(case> (^ (#try.Success (////synthesis.variant [leftsS right?S valueS])))
(let [tagS (if right?S (inc leftsS) leftsS)]
- (and (n/= tagA tagS)
- (|> tagS (n/= (dec size)) (bit@= right?S))
+ (and (n.= tagA tagS)
+ (|> tagS (n.= (dec size)) (bit@= right?S))
(//primitive.corresponds? memberA valueS)))
_
@@ -52,14 +54,14 @@
(def: tuple
Test
(do r.monad
- [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2))))
+ [size (|> r.nat (:: @ map (|>> (n.% 10) (n.max 2))))
membersA (r.list size //primitive.primitive)]
(_.test "Can synthesize tuple."
(|> (////analysis.tuple membersA)
//.phase
(///.run [///bundle.empty ////synthesis.init])
(case> (^ (#try.Success (////synthesis.tuple membersS)))
- (and (n/= size (list.size membersS))
+ (and (n.= size (list.size membersS))
(list.every? (product.uncurry //primitive.corresponds?)
(list.zip2 membersA membersS)))