aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/test/test/lux.lux68
1 files changed, 27 insertions, 41 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index 211cf6d6b..ec3c82197 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -1,7 +1,7 @@
(.module:
lux
lux/test
- (lux (control ["M" monad #+ do Monad])
+ (lux (control [monad #+ do])
[math]
["r" math/random]
(data [maybe]
@@ -27,58 +27,44 @@
))))
(do-template [category rand-gen even? odd? = < >]
- [(context: (format "[" category "] " "Moving up-down or down-up should result in same value.")
+ [(context: (format "[" category "] " "Simple operations.")
(<| (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")
- (<| (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.")
- (<| (times +100)
- (do @
- [value rand-gen]
- (test ""
- (if (even? value)
- (and (|> value inc odd?)
- (|> value dec odd?))
- (and (|> value inc even?)
- (|> value dec even?)))))))]
+ ($_ seq
+ (test (format "[" category "] " "Moving up-down or down-up should result in same value.")
+ (and (|> value inc dec (= value))
+ (|> value dec inc (= value))))
+ (test (format "[" category "] " "(x+1) > x && (x-1) < x")
+ (and (|> value inc (> value))
+ (|> value dec (< value))))
+ (test (format "[" category "] " "Every odd/even number is surrounded by two of the other kind.")
+ (if (even? value)
+ (and (|> value inc odd?)
+ (|> value dec odd?))
+ (and (|> value inc even?)
+ (|> value dec even?))))))))]
["Nat" r.nat n/even? n/odd? n/= n/< n/>]
["Int" r.int i/even? i/odd? i/= i/< i/>]
)
(do-template [category rand-gen = < > <= >= min max]
- [(context: (format "[" category "] " "The symmetry of numerical comparisons.")
- (<| (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.")
+ [(context: (format "[" category "] " "(More) simple operations.")
(<| (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)))
- )))))]
+ (seq (test (format "[" category "] " "The symmetry of numerical comparisons.")
+ (or (= x y)
+ (if (< y x)
+ (> x y)
+ (< x y))))
+ (test (format "[" category "] " "Minimums and maximums.")
+ (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]
@@ -145,7 +131,7 @@
(def: frac-rev
(r.Random Rev)
(|> r.rev
- (:: r.Functor<Random> map (|>> (bit.left-shift +11) (bit.right-shift +11)))))
+ (:: r.Functor<Random> map (|>> (bit.left-shift +11) (bit.logical-right-shift +11)))))
(do-template [category rand-gen -> <- = <cap>]
[(context: (format "[" category "] " "Numeric conversions")