aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test/test/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2017-10-20 19:09:34 -0400
committerEduardo Julian2017-10-20 19:09:34 -0400
commite9368bc5f75345c81bd7ded21e07a4436641821a (patch)
tree41b2dded0775543d28b433b8a5bd39eb08b5787e /stdlib/test/test/lux.lux
parenteb770f4473a904285ea559279331a93cdb5b7ded (diff)
- Replaced the "#seed" and "#times" options for "seed" and "times" test combinators.
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux.lux186
1 files changed, 105 insertions, 81 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index f44430c6c..9c348720b 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -12,37 +12,45 @@
(meta ["s" syntax #+ syntax:])))
(context: "Value identity."
- [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
- x (r;text size)
- y (r;text size)]
- ($_ seq
- (test "Every value is identical to itself, and the 'id' function doesn't change values in any way."
- (and (is x x)
- (is x (id x))))
-
- (test "Values created separately can't be identical."
- (not (is x y)))
- ))
+ (<| (times +100)
+ (do @
+ [size (|> r;nat (:: @ map (|>. (n.% +100) (n.max +10))))
+ x (r;text size)
+ y (r;text size)]
+ ($_ seq
+ (test "Every value is identical to itself, and the 'id' function doesn't change values in any way."
+ (and (is x x)
+ (is x (id x))))
+
+ (test "Values created separately can't be identical."
+ (not (is x y)))
+ ))))
(do-template [category rand-gen inc dec even? odd? = < >]
[(context: (format "[" category "] " "Moving up-down or down-up should result in same value.")
- [value rand-gen]
- (test "" (and (|> value inc dec (= value))
- (|> value dec inc (= value)))))
+ (<| (times +100)
+ (do @
+ [value rand-gen]
+ (test "" (and (|> value inc dec (= value))
+ (|> value dec inc (= value)))))))
(context: (format "[" category "] " "(x+1) > x && (x-1) < x")
- [value rand-gen]
- (test "" (and (|> value inc (> value))
- (|> value dec (< value)))))
+ (<| (times +100)
+ (do @
+ [value rand-gen]
+ (test "" (and (|> value inc (> value))
+ (|> value dec (< value)))))))
(context: (format "[" category "] " "Every odd/even number is surrounded by two of the other kind.")
- [value rand-gen]
- (test ""
- (if (even? value)
- (and (|> value inc odd?)
- (|> value dec odd?))
- (and (|> value inc even?)
- (|> value dec even?)))))]
+ (<| (times +100)
+ (do @
+ [value rand-gen]
+ (test ""
+ (if (even? value)
+ (and (|> value inc odd?)
+ (|> value dec odd?))
+ (and (|> value inc even?)
+ (|> value dec even?)))))))]
["Nat" r;nat n.inc n.dec n.even? n.odd? n.= n.< n.>]
["Int" r;int i.inc i.dec i.even? i.odd? i.= i.< i.>]
@@ -50,23 +58,27 @@
(do-template [category rand-gen = < > <= >= min max]
[(context: (format "[" category "] " "The symmetry of numerical comparisons.")
- [x rand-gen
- y rand-gen]
- (test ""
- (or (= x y)
- (if (< y x)
- (> x y)
- (< x y)))))
+ (<| (times +100)
+ (do @
+ [x rand-gen
+ y rand-gen]
+ (test ""
+ (or (= x y)
+ (if (< y x)
+ (> x y)
+ (< x y)))))))
(context: (format "[" category "] " "Minimums and maximums.")
- [x rand-gen
- y rand-gen]
- (test ""
- (and (and (<= x (min x y))
- (<= y (min x y)))
- (and (>= x (max x y))
- (>= y (max x y)))
- )))]
+ (<| (times +100)
+ (do @
+ [x rand-gen
+ y rand-gen]
+ (test ""
+ (and (and (<= x (min x y))
+ (<= y (min x y)))
+ (and (>= x (max x y))
+ (>= y (max x y)))
+ )))))]
["Int" r;int i.= i.< i.> i.<= i.>= i.min i.max]
["Nat" r;nat n.= n.< n.> n.<= n.>= n.min n.max]
@@ -76,45 +88,53 @@
(do-template [category rand-gen = + - * / <%> > <0> <1> <factor> %x <cap> <prep>]
[(context: (format "[" category "] " "Additive identity")
- [x rand-gen]
- (test ""
- (and (|> x (+ <0>) (= x))
- (|> x (- <0>) (= x)))))
+ (<| (times +100)
+ (do @
+ [x rand-gen]
+ (test ""
+ (and (|> x (+ <0>) (= x))
+ (|> x (- <0>) (= x)))))))
(context: (format "[" category "] " "Addition & Substraction")
- [x (:: @ map <prep> rand-gen)
- y (:: @ map <prep> rand-gen)
- #let [x (* <factor> x)
- y (* <factor> y)]]
- (test ""
- (and (|> x (- y) (+ y) (= x))
- (|> x (+ y) (- y) (= x)))))
+ (<| (times +100)
+ (do @
+ [x (:: @ map <prep> rand-gen)
+ y (:: @ map <prep> rand-gen)
+ #let [x (* <factor> x)
+ y (* <factor> y)]]
+ (test ""
+ (and (|> x (- y) (+ y) (= x))
+ (|> x (+ y) (- y) (= x)))))))
(context: (format "[" category "] " "Multiplicative identity")
- [x rand-gen]
- (test ""
- ## Skip this test for Deg
- ## because Deg division loses the last
- ## 32 bits of precision.
- (or (text/= "Deg" category)
- (and (|> x (* <1>) (= x))
- (|> x (/ <1>) (= x))))))
+ (<| (times +100)
+ (do @
+ [x rand-gen]
+ (test ""
+ ## Skip this test for Deg
+ ## because Deg division loses the last
+ ## 32 bits of precision.
+ (or (text/= "Deg" category)
+ (and (|> x (* <1>) (= x))
+ (|> x (/ <1>) (= x))))))))
(context: (format "[" category "] " "Multiplication & Division")
- [x (:: @ map <cap> rand-gen)
- y (|> rand-gen
- (:: @ map <cap>)
- (r;filter (|>. (= <0>) not)))
- #let [r (<%> y x)
- x' (- r x)]]
- (test ""
- ## Skip this test for Deg
- ## because Deg division loses the last
- ## 32 bits of precision.
- (or (text/= "Deg" category)
- (or (> x' y)
- (|> x' (/ y) (* y) (= x'))))
- ))]
+ (<| (times +100)
+ (do @
+ [x (:: @ map <cap> rand-gen)
+ y (|> rand-gen
+ (:: @ map <cap>)
+ (r;filter (|>. (= <0>) not)))
+ #let [r (<%> y x)
+ x' (- r x)]]
+ (test ""
+ ## Skip this test for Deg
+ ## because Deg division loses the last
+ ## 32 bits of precision.
+ (or (text/= "Deg" category)
+ (or (> x' y)
+ (|> x' (/ y) (* y) (= x'))))
+ ))))]
["Nat" r;nat n.= n.+ n.- n.* n./ n.% n.> +0 +1 +1000000 %n (n.% +1000) id]
["Int" r;int i.= i.+ i.- i.* i./ i.% i.> 0 1 1000000 %i (i.% 1000) id]
@@ -124,10 +144,12 @@
(do-template [category rand-gen -> <- = <cap> %a %z]
[(context: (format "[" category "] " "Numeric conversions")
- [value rand-gen
- #let [value (<cap> value)]]
- (test ""
- (|> value -> <- (= value))))]
+ (<| (times +100)
+ (do @
+ [value rand-gen
+ #let [value (<cap> value)]]
+ (test ""
+ (|> value -> <- (= value))))))]
["Int->Nat" r;int int-to-nat nat-to-int i.= (i.% 1000000) %i %n]
["Nat->Int" r;nat nat-to-int int-to-nat n.= (n.% +1000000) %n %i]
@@ -173,11 +195,13 @@
(i.+ (i.* x x) (i.* y y)))
(context: "Templates."
- [x r;int
- y r;int]
- (test "Template application is a stand-in for the templated code."
- (i.= (i.+ (i.* x x) (i.* y y))
- (hypotenuse x y))))
+ (<| (times +100)
+ (do @
+ [x r;int
+ y r;int]
+ (test "Template application is a stand-in for the templated code."
+ (i.= (i.+ (i.* x x) (i.* y y))
+ (hypotenuse x y))))))
(context: "Cross-platform support."
($_ seq