From 6425e4cfe470b54d76bb316cbdb6fdb21dd63130 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 24 Jul 2019 23:50:16 -0400 Subject: No more "r/"-prefixed functions. --- stdlib/source/test/lux.lux | 75 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 37 deletions(-) (limited to 'stdlib/source/test/lux.lux') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index e1039d506..597f6d83e 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -21,7 +21,7 @@ [number ["." i64] ["." int] - ["." rev] + ["r" rev] ["f" frac]]] ["." math] ["_" test (#+ Test)] @@ -32,7 +32,8 @@ [language (#+)] [territory (#+)]] ["%" data/text/format (#+ format)] - ["r" math/random (#+ Random) ("#@." functor)] + [math + ["." random (#+ Random) ("#@." functor)]] ## TODO: Test these modules [data [format @@ -137,23 +138,23 @@ (def: identity Test - (do r.monad - [self (r.unicode 1)] + (do random.monad + [self (random.unicode 1)] ($_ _.and (_.test "Every value is identical to itself." (is? self self)) (_.test "The identity function doesn't change values in any way." (is? self (function.identity self))) (do @ - [other (r.unicode 1)] + [other (random.unicode 1)] (_.test "Values created separately can't be identical." (not (is? self other)))) ))) (def: increment-and-decrement Test - (do r.monad - [value r.i64] + (do random.monad + [value random.i64] ($_ _.and (_.test "'inc' and 'dec' are opposites." (and (|> value inc dec (n/= value)) @@ -169,7 +170,7 @@ (def: (even-or-odd rand-gen even? odd?) (All [a] (-> (Random (I64 a)) (Predicate (I64 a)) (Predicate (I64 a)) Test)) - (do r.monad + (do random.monad [value rand-gen] ($_ _.and (_.test "Every number is either even or odd." @@ -192,7 +193,7 @@ (def: (choice rand-gen = [< choose]) (All [a] (-> (Random a) (Equivalence a) [(Order a) (Choice a)] Test)) - (do r.monad + (do random.monad [left rand-gen right rand-gen #let [choice (choose left right)]] @@ -215,22 +216,22 @@ (def: (conversion rand-gen forward backward =) (All [a b] (-> (Random a) (-> a b) (-> b a) (Equivalence a) Test)) - (do r.monad + (do random.monad [value rand-gen] (_.test "Can convert between types in a lossless way." (|> value forward backward (= value))))) (def: frac-rev - (r.Random Rev) + (Random Rev) (let [bits-to-ignore 11] - (:: r.functor map (i64.left-shift bits-to-ignore) r.rev))) + (:: random.functor map (i64.left-shift bits-to-ignore) random.rev))) (def: prelude-macros Test ($_ _.and - (do r.monad - [factor (r@map (|>> (n/% 10) (n/max 1)) r.nat) - iterations (r@map (n/% 100) r.nat) + (do random.monad + [factor (random@map (|>> (n/% 10) (n/max 1)) random.nat) + iterations (random@map (n/% 100) random.nat) #let [expected (n/* factor iterations)]] (_.test "Can write loops." (n/= expected @@ -240,10 +241,10 @@ (recur (inc counter) (n/+ factor value)) value))))) - (do r.monad - [first r.nat - second r.nat - third r.nat] + (do random.monad + [first random.nat + second random.nat + third random.nat] (_.test "Can create lists easily through macros." (and (case (list first second third) (#.Cons first' (#.Cons second' (#.Cons third' #.Nil))) @@ -276,19 +277,19 @@ (def: templates Test - (do r.monad - [cat0 r.nat - cat1 r.nat] + (do random.monad + [cat0 random.nat + cat1 random.nat] (_.test "Template application is a stand-in for the templated code." (n/= (n/+ (n/* cat0 cat0) (n/* cat1 cat1)) (quadrance cat0 cat1))))) (def: cross-platform-support Test - (do r.monad - [on-default r.nat - on-fake-host r.nat - on-valid-host r.nat] + (do random.monad + [on-default random.nat + on-fake-host random.nat + on-valid-host random.nat] ($_ _.and (_.test "Can provide default in case there is no particular host/platform support." (n/= on-default @@ -311,19 +312,19 @@ (<| (_.context "Even or odd.") ($_ _.and (<| (_.context "Natural numbers.") - (..even-or-odd r.nat n/even? n/odd?)) + (..even-or-odd random.nat n/even? n/odd?)) (<| (_.context "Integers.") - (..even-or-odd r.int i/even? i/odd?)))) + (..even-or-odd random.int i/even? i/odd?)))) (<| (_.context "Minimum and maximum.") (`` ($_ _.and (~~ (template [<=> ] [(<| (_.context ) (..minimum-and-maximum <=> [ ] [ ]))] - [i/= i/< i/min i/> i/max r.int "Integers."] - [n/= n/< n/min n/> n/max r.nat "Natural numbers."] - [r/= r/< r/min r/> r/max r.rev "Revolutions."] - [f.= f.< f.min f.> f.max r.safe-frac "Fractions."] + [i/= i/< i/min i/> i/max random.int "Integers."] + [n/= n/< n/min n/> n/max random.nat "Natural numbers."] + [r.= r.< r.min r.> r.max random.rev "Revolutions."] + [f.= f.< f.min f.> f.max random.safe-frac "Fractions."] ))))) (<| (_.context "Conversion.") (`` ($_ _.and @@ -332,11 +333,11 @@ " " (%.name (name-of )))) (..conversion <=>))] - [i/= .nat .int (r@map (i/% +1,000,000) r.int)] - [n/= .int .nat (r@map (n/% 1,000,000) r.nat)] - [i/= int.frac f.int (r@map (i/% +1,000,000) r.int)] - [f.= f.int int.frac (r@map (|>> (i/% +1,000,000) int.frac) r.int)] - [r/= rev.frac f.rev frac-rev] + [i/= .nat .int (random@map (i/% +1,000,000) random.int)] + [n/= .int .nat (random@map (n/% 1,000,000) random.nat)] + [i/= int.frac f.int (random@map (i/% +1,000,000) random.int)] + [f.= f.int int.frac (random@map (|>> (i/% +1,000,000) int.frac) random.int)] + [r.= r.frac f.rev frac-rev] ))))) (<| (_.context "Prelude macros.") ..prelude-macros) -- cgit v1.2.3