From 604e6b0bf1a363b0bb03460d1d6512c36f3c8120 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 9 Jul 2018 21:39:52 -0400 Subject: - Fixes: Part 0. --- stdlib/test/test/lux.lux | 68 +++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 41 deletions(-) (limited to 'stdlib/test') 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 map (|>> (bit.left-shift +11) (bit.right-shift +11))))) + (:: r.Functor map (|>> (bit.left-shift +11) (bit.logical-right-shift +11))))) (do-template [category rand-gen -> <- = ] [(context: (format "[" category "] " "Numeric conversions") -- cgit v1.2.3