diff options
author | Eduardo Julian | 2017-04-03 18:18:34 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-04-03 18:18:34 -0400 |
commit | 82c955d5777ecb87b53bafcc658683d5a76e9a3c (patch) | |
tree | 5e9c638d7c9e3e04c0db94012184f606f7f71573 /stdlib/test | |
parent | 65b39c7d66244d275ad75c734bc42b0588379bfb (diff) |
- Implemented Int encoding/decoding in the standard library.
- Moved some type-constructors for building functor types into the lux/control/functor module.
- Renamed Ord to Order.
- Renamed Env to Reader.
Diffstat (limited to 'stdlib/test')
-rw-r--r-- | stdlib/test/test/lux/codata/reader.lux (renamed from stdlib/test/test/lux/codata/env.lux) | 18 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/char.lux | 6 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/coll/ordered.lux | 10 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/number.lux | 82 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/text.lux | 2 | ||||
-rw-r--r-- | stdlib/test/tests.lux | 2 |
6 files changed, 60 insertions, 60 deletions
diff --git a/stdlib/test/test/lux/codata/env.lux b/stdlib/test/test/lux/codata/reader.lux index bac90d3b0..021ee1ab9 100644 --- a/stdlib/test/test/lux/codata/env.lux +++ b/stdlib/test/test/lux/codata/reader.lux @@ -6,19 +6,19 @@ text/format [number]) (codata function - ["&" env]) + ["&" reader]) pipe) lux/test) -(test: "Envs" +(test: "Readers" ($_ seq (assert "" (i.= 123 (&;run 123 &;ask))) (assert "" (i.= 246 (&;run 123 (&;local (i.* 2) &;ask)))) - (assert "" (i.= 134 (&;run 123 (:: &;Functor<Env> map i.inc (i.+ 10))))) - (assert "" (i.= 10 (&;run 123 (:: &;Applicative<Env> wrap 10)))) - (assert "" (i.= 30 (&;run 123 (let [(^open "&/") &;Applicative<Env>] + (assert "" (i.= 134 (&;run 123 (:: &;Functor<Reader> map i.inc (i.+ 10))))) + (assert "" (i.= 10 (&;run 123 (:: &;Applicative<Reader> wrap 10)))) + (assert "" (i.= 30 (&;run 123 (let [(^open "&/") &;Applicative<Reader>] (&/apply (&/wrap (i.+ 10)) (&/wrap 20)))))) - (assert "" (i.= 30 (&;run 123 (do &;Monad<Env> + (assert "" (i.= 30 (&;run 123 (do &;Monad<Reader> [f (wrap i.+) x (wrap 10) y (wrap 20)] @@ -26,9 +26,9 @@ (test: "Monad transformer" (let [(^open "io/") io;Monad<IO>] - (assert "Can add env functionality to any monad." - (|> (do (&;EnvT io;Monad<IO>) - [a (&;lift-env (io/wrap 123)) + (assert "Can add reader functionality to any monad." + (|> (do (&;ReaderT io;Monad<IO>) + [a (&;lift-reader (io/wrap 123)) b (wrap 456)] (wrap (i.+ a b))) (&;run "") diff --git a/stdlib/test/test/lux/data/char.lux b/stdlib/test/test/lux/data/char.lux index 6b7175de7..5025a1283 100644 --- a/stdlib/test/test/lux/data/char.lux +++ b/stdlib/test/test/lux/data/char.lux @@ -33,9 +33,9 @@ (:: Eq<Char> = value)))) (assert "Characters have an ordering relationship." - (if (:: Ord<Char> < other value) - (:: Ord<Char> > value other) - (:: Ord<Char> >= other value))) + (if (:: Order<Char> < other value) + (:: Order<Char> > value other) + (:: Order<Char> >= other value))) )) (test: "Special cases" diff --git a/stdlib/test/test/lux/data/coll/ordered.lux b/stdlib/test/test/lux/data/coll/ordered.lux index 213a568c1..ffc2bf309 100644 --- a/stdlib/test/test/lux/data/coll/ordered.lux +++ b/stdlib/test/test/lux/data/coll/ordered.lux @@ -20,9 +20,9 @@ [sizeL gen-nat sizeR gen-nat setL (|> (R;set number;Hash<Nat> sizeL gen-nat) - (:: @ map (|>. S;to-list (&;from-list number;Ord<Nat>)))) + (:: @ map (|>. S;to-list (&;from-list number;Order<Nat>)))) setR (|> (R;set number;Hash<Nat> sizeR gen-nat) - (:: @ map (|>. S;to-list (&;from-list number;Ord<Nat>)))) + (:: @ map (|>. S;to-list (&;from-list number;Order<Nat>)))) #let [(^open "&/") &;Eq<Set>]] ($_ seq (assert "I can query the size of a set." @@ -30,7 +30,7 @@ (assert "Converting sets to/from lists can't change their values." (|> setL - &;to-list (&;from-list number;Ord<Nat>) + &;to-list (&;from-list number;Order<Nat>) (&/= setL))) (assert "Order is preserved." @@ -51,11 +51,11 @@ (assert "Union with the empty set leaves a set unchanged." (&/= setL - (&;union (&;new number;Ord<Nat>) + (&;union (&;new number;Order<Nat>) setL))) (assert "Intersection with the empty set results in the empty set." - (let [empty-set (&;new number;Ord<Nat>)] + (let [empty-set (&;new number;Order<Nat>)] (&/= empty-set (&;intersection empty-set setL)))) diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 8424c82a3..ad89649ba 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -9,26 +9,26 @@ pipe) lux/test) -(do-template [category rand-gen <Eq> <Ord>] - [(test: (format "[" category "] " "Eq & Ord") +(do-template [category rand-gen <Eq> <Order>] + [(test: (format "[" category "] " "Eq & Order") [x rand-gen y rand-gen] (assert "" (and (:: <Eq> = x x) (or (:: <Eq> = x y) - (:: <Ord> < y x) - (:: <Ord> > y x)))))] + (:: <Order> < y x) + (:: <Order> > y x)))))] - ["Nat" R;nat Eq<Nat> Ord<Nat>] - ["Int" R;int Eq<Int> Ord<Int>] - ["Real" R;real Eq<Real> Ord<Real>] - ["Deg" R;deg Eq<Deg> Ord<Deg>] + ["Nat" R;nat Eq<Nat> Order<Nat>] + ["Int" R;int Eq<Int> Order<Int>] + ["Real" R;real Eq<Real> Order<Real>] + ["Deg" R;deg Eq<Deg> Order<Deg>] ) -(do-template [category rand-gen <Number> <Ord>] +(do-template [category rand-gen <Number> <Order>] [(test: (format "[" category "] " "Number") [x rand-gen #let [(^open) <Number> - (^open) <Ord>]] + (^open) <Order>]] (assert "" (and (>= x (abs x)) ## abs(0.0) == 0.0 && negate(abs(0.0)) == -0.0 (or (Text/= "Real" category) @@ -40,16 +40,16 @@ (abs x)))))))] ## ["Nat" R;nat Number<Nat>] - ["Int" R;int Number<Int> Ord<Int>] - ["Real" R;real Number<Real> Ord<Real>] - ["Deg" R;deg Number<Deg> Ord<Deg>] + ["Int" R;int Number<Int> Order<Int>] + ["Real" R;real Number<Real> Order<Real>] + ["Deg" R;deg Number<Deg> Order<Deg>] ) -(do-template [category rand-gen <Enum> <Number> <Ord>] +(do-template [category rand-gen <Enum> <Number> <Order>] [(test: (format "[" category "] " "Enum") [x rand-gen] (assert "" (let [(^open) <Number> - (^open) <Ord>] + (^open) <Order>] (and (> x (:: <Enum> succ x)) (< x @@ -61,52 +61,52 @@ (|> x (:: <Enum> succ) (:: <Enum> pred))) ))))] - ["Nat" R;nat Enum<Nat> Number<Nat> Ord<Nat>] - ["Int" R;int Enum<Int> Number<Int> Ord<Int>] + ["Nat" R;nat Enum<Nat> Number<Nat> Order<Nat>] + ["Int" R;int Enum<Int> Number<Int> Order<Int>] ) -(do-template [category rand-gen <Number> <Ord> <Interval> <test>] +(do-template [category rand-gen <Number> <Order> <Interval> <test>] [(test: (format "[" category "] " "Interval") [x (|> rand-gen (R;filter <test>)) #let [(^open) <Number> - (^open) <Ord>]] + (^open) <Order>]] (assert "" (and (<= x (:: <Interval> bottom)) (>= x (:: <Interval> top)))))] - ["Nat" R;nat Number<Nat> Ord<Nat> Interval<Nat> (lambda [_] true)] - ["Int" R;int Number<Int> Ord<Int> Interval<Int> (lambda [_] true)] + ["Nat" R;nat Number<Nat> Order<Nat> Interval<Nat> (lambda [_] true)] + ["Int" R;int Number<Int> Order<Int> Interval<Int> (lambda [_] true)] ## Both min and max values will be positive (thus, greater than zero) - ["Real" R;real Number<Real> Ord<Real> Interval<Real> (r.> 0.0)] - ["Deg" R;deg Number<Deg> Ord<Deg> Interval<Deg> (lambda [_] true)] + ["Real" R;real Number<Real> Order<Real> Interval<Real> (r.> 0.0)] + ["Deg" R;deg Number<Deg> Order<Deg> Interval<Deg> (lambda [_] true)] ) -(do-template [category rand-gen <Number> <Ord> <Monoid> <cap> <test>] +(do-template [category rand-gen <Number> <Order> <Monoid> <cap> <test>] [(test: (format "[" category "] " "Monoid") [x (|> rand-gen (:: @ map (|>. (:: <Number> abs) <cap>)) (R;filter <test>)) #let [(^open) <Number> - (^open) <Ord> + (^open) <Order> (^open) <Monoid>]] (assert "Appending to unit doesn't change the value." (and (= x (append unit x)) (= x (append x unit)) (= unit (append unit unit)))))] - ["Nat/Add" R;nat Number<Nat> Ord<Nat> Add@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Nat/Mul" R;nat Number<Nat> Ord<Nat> Mul@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Nat/Min" R;nat Number<Nat> Ord<Nat> Min@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Nat/Max" R;nat Number<Nat> Ord<Nat> Max@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Int/Add" R;int Number<Int> Ord<Int> Add@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Int/Mul" R;int Number<Int> Ord<Int> Mul@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Int/Min" R;int Number<Int> Ord<Int> Min@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Int/Max" R;int Number<Int> Ord<Int> Max@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Real/Add" R;real Number<Real> Ord<Real> Add@Monoid<Real> (r.% 1000.0) (r.> 0.0)] - ["Real/Mul" R;real Number<Real> Ord<Real> Mul@Monoid<Real> (r.% 1000.0) (r.> 0.0)] - ["Real/Min" R;real Number<Real> Ord<Real> Min@Monoid<Real> (r.% 1000.0) (r.> 0.0)] - ["Real/Max" R;real Number<Real> Ord<Real> Max@Monoid<Real> (r.% 1000.0) (r.> 0.0)] - ["Deg/Add" R;deg Number<Deg> Ord<Deg> Add@Monoid<Deg> (d.% .125) (lambda [_] true)] - ## ["Deg/Mul" R;deg Number<Deg> Ord<Deg> Mul@Monoid<Deg> (d.% .125) (lambda [_] true)] - ["Deg/Min" R;deg Number<Deg> Ord<Deg> Min@Monoid<Deg> (d.% .125) (lambda [_] true)] - ["Deg/Max" R;deg Number<Deg> Ord<Deg> Max@Monoid<Deg> (d.% .125) (lambda [_] true)] + ["Nat/Add" R;nat Number<Nat> Order<Nat> Add@Monoid<Nat> (n.% +1000) (lambda [_] true)] + ["Nat/Mul" R;nat Number<Nat> Order<Nat> Mul@Monoid<Nat> (n.% +1000) (lambda [_] true)] + ["Nat/Min" R;nat Number<Nat> Order<Nat> Min@Monoid<Nat> (n.% +1000) (lambda [_] true)] + ["Nat/Max" R;nat Number<Nat> Order<Nat> Max@Monoid<Nat> (n.% +1000) (lambda [_] true)] + ["Int/Add" R;int Number<Int> Order<Int> Add@Monoid<Int> (i.% 1000) (lambda [_] true)] + ["Int/Mul" R;int Number<Int> Order<Int> Mul@Monoid<Int> (i.% 1000) (lambda [_] true)] + ["Int/Min" R;int Number<Int> Order<Int> Min@Monoid<Int> (i.% 1000) (lambda [_] true)] + ["Int/Max" R;int Number<Int> Order<Int> Max@Monoid<Int> (i.% 1000) (lambda [_] true)] + ["Real/Add" R;real Number<Real> Order<Real> Add@Monoid<Real> (r.% 1000.0) (r.> 0.0)] + ["Real/Mul" R;real Number<Real> Order<Real> Mul@Monoid<Real> (r.% 1000.0) (r.> 0.0)] + ["Real/Min" R;real Number<Real> Order<Real> Min@Monoid<Real> (r.% 1000.0) (r.> 0.0)] + ["Real/Max" R;real Number<Real> Order<Real> Max@Monoid<Real> (r.% 1000.0) (r.> 0.0)] + ["Deg/Add" R;deg Number<Deg> Order<Deg> Add@Monoid<Deg> (d.% .125) (lambda [_] true)] + ## ["Deg/Mul" R;deg Number<Deg> Order<Deg> Mul@Monoid<Deg> (d.% .125) (lambda [_] true)] + ["Deg/Min" R;deg Number<Deg> Order<Deg> Min@Monoid<Deg> (d.% .125) (lambda [_] true)] + ["Deg/Max" R;deg Number<Deg> Order<Deg> Max@Monoid<Deg> (d.% .125) (lambda [_] true)] ) (do-template [<category> <rand-gen> <Eq> <Codec>] diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux index 72e633847..ce72cd520 100644 --- a/stdlib/test/test/lux/data/text.lux +++ b/stdlib/test/test/lux/data/text.lux @@ -127,7 +127,7 @@ ))) (test: "Structures" - (let [(^open "&/") &;Ord<Text>] + (let [(^open "&/") &;Order<Text>] ($_ seq (assert "" (&/< "bcd" "abc")) (assert "" (not (&/< "abc" "abc"))) diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux index 2a7615dac..53a003756 100644 --- a/stdlib/test/tests.lux +++ b/stdlib/test/tests.lux @@ -13,7 +13,7 @@ ["_;" lexer] (lexer ["_;" regex]) (codata ["_;" cont] - ["_;" env] + ["_;" reader] ["_;" state] ["_;" thunk] (coll ["_;" stream])) |