aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-09-19 21:52:42 -0400
committerEduardo Julian2017-09-19 21:52:42 -0400
commit70534ffd9c346ac23f9d5574b9c7820dccebc350 (patch)
treee2370a43a8bb2bdcb349d5bbbe477312859365f3 /stdlib/test
parente717f33e192a5969760c033c47f9c4709485dd76 (diff)
- Some refactoring.
- Moved "assume" and "default" to lux/data/maybe.
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux.lux7
-rw-r--r--stdlib/test/test/lux/concurrency/stm.lux5
-rw-r--r--stdlib/test/test/lux/data/coll/array.lux6
-rw-r--r--stdlib/test/test/lux/data/coll/dict.lux11
-rw-r--r--stdlib/test/test/lux/data/coll/list.lux18
-rw-r--r--stdlib/test/test/lux/data/coll/priority-queue.lux7
-rw-r--r--stdlib/test/test/lux/data/coll/stack.lux5
-rw-r--r--stdlib/test/test/lux/data/coll/stream.lux11
-rw-r--r--stdlib/test/test/lux/data/coll/tree/zipper.lux7
-rw-r--r--stdlib/test/test/lux/data/coll/vector.lux7
-rw-r--r--stdlib/test/test/lux/data/format/xml.lux3
-rw-r--r--stdlib/test/test/lux/type.lux6
12 files changed, 48 insertions, 45 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index 41b3bc555..546d7f14f 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -5,7 +5,8 @@
[io]
[math]
["R" math/random]
- (data [text "T/" Eq<Text>]
+ (data [maybe]
+ [text "T/" Eq<Text>]
text/format)
[macro]
(macro ["s" syntax #+ syntax:])))
@@ -161,10 +162,10 @@
false)))
(test "Can have defaults for Maybe values."
- (and (is "yolo" (default "yolo"
+ (and (is "yolo" (maybe;default "yolo"
#;None))
- (is "lol" (default "yolo"
+ (is "lol" (maybe;default "yolo"
(#;Some "lol")))))
))
diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux
index b7403d8d5..ade1700b5 100644
--- a/stdlib/test/test/lux/concurrency/stm.lux
+++ b/stdlib/test/test/lux/concurrency/stm.lux
@@ -3,6 +3,7 @@
(lux [io]
(control ["M" monad #+ do Monad])
(data [number]
+ [maybe]
(coll [list "" Functor<List> "List/" Fold<List>])
text/format)
(concurrency ["&" stm]
@@ -25,9 +26,9 @@
_ (&;update (i.* 3) _var)]
(&;read _var)))
?c1+changes' changes
- #let [[c1 changes'] (default [-1 changes] ?c1+changes')]
+ #let [[c1 changes'] (maybe;default [-1 changes] ?c1+changes')]
?c2+changes' changes'
- #let [[c2 changes'] (default [-1 changes] ?c2+changes')]]
+ #let [[c2 changes'] (maybe;default [-1 changes] ?c2+changes')]]
($_ seq
(test "Can read STM vars."
(i.= 0 output1))
diff --git a/stdlib/test/test/lux/data/coll/array.lux b/stdlib/test/test/lux/data/coll/array.lux
index b98c20c66..3f344a1be 100644
--- a/stdlib/test/test/lux/data/coll/array.lux
+++ b/stdlib/test/test/lux/data/coll/array.lux
@@ -5,7 +5,8 @@
[io]
(data (coll ["&" array]
[list])
- [number])
+ [number]
+ [maybe])
["R" math/random])
lux/test)
@@ -51,8 +52,7 @@
idx (:: @ map (n.% size) R;nat)
array (|> (R;array size R;nat)
(R;filter (|>. &;to-list (list;any? n.odd?))))
- #let [value (default (undefined)
- (&;get idx array))]]
+ #let [value (maybe;assume (&;get idx array))]]
($_ seq
(test "Shouldn't be able to find a value in an unoccupied cell."
(case (&;get idx (&;remove idx array))
diff --git a/stdlib/test/test/lux/data/coll/dict.lux b/stdlib/test/test/lux/data/coll/dict.lux
index b317cdfa8..defea0534 100644
--- a/stdlib/test/test/lux/data/coll/dict.lux
+++ b/stdlib/test/test/lux/data/coll/dict.lux
@@ -6,6 +6,7 @@
(data [text]
text/format
[number]
+ [maybe]
(coll ["&" dict]
[list "L/" Fold<List> Functor<List>]))
["r" math/random])
@@ -59,7 +60,7 @@
(test "Shouldn't be able to put~ an existing key."
(or (n.= +0 size)
- (let [first-key (|> dict &;keys list;head (default (undefined)))]
+ (let [first-key (|> dict &;keys list;head maybe;assume)]
(case (&;get first-key (&;put~ first-key test-val dict))
(#;Some v) (not (n.= test-val v))
_ true))))
@@ -115,13 +116,11 @@
(test "Should be able to re-bind existing values to different keys."
(or (n.= +0 size)
- (let [first-key (|> dict &;keys list;head (default (undefined)))
+ (let [first-key (|> dict &;keys list;head maybe;assume)
rebound (&;re-bind first-key non-key dict)]
(and (n.= (&;size dict) (&;size rebound))
(&;contains? non-key rebound)
(not (&;contains? first-key rebound))
- (n.= (default (undefined)
- (&;get first-key dict))
- (default (undefined)
- (&;get non-key rebound)))))))
+ (n.= (maybe;assume (&;get first-key dict))
+ (maybe;assume (&;get non-key rebound)))))))
))
diff --git a/stdlib/test/test/lux/data/coll/list.lux b/stdlib/test/test/lux/data/coll/list.lux
index 08bd547f4..087c9d831 100644
--- a/stdlib/test/test/lux/data/coll/list.lux
+++ b/stdlib/test/test/lux/data/coll/list.lux
@@ -7,7 +7,8 @@
[text "Text/" Monoid<Text>]
[number]
[bool]
- [product])
+ [product]
+ [maybe])
["R" math/random])
lux/test)
@@ -56,8 +57,7 @@
(&;any? (bool;complement n.even?) sample)))
(test "Any element of the list can be considered its member."
- (let [elem (default (undefined)
- (&;nth idx sample))]
+ (let [elem (maybe;assume (&;nth idx sample))]
(&;member? number;Eq<Nat> sample elem)))
))
@@ -72,19 +72,15 @@
(^open "&/") &;Functor<List>]]
($_ seq
(test "Appending the head and the tail should yield the original list."
- (let [head (default (undefined)
- (&;head sample))
- tail (default (undefined)
- (&;tail sample))]
+ (let [head (maybe;assume (&;head sample))
+ tail (maybe;assume (&;tail sample))]
(= sample
(#;Cons head tail))))
(test "Appending the inits and the last should yield the original list."
(let [(^open) &;Monoid<List>
- inits (default (undefined)
- (&;inits sample))
- last (default (undefined)
- (&;last sample))]
+ inits (maybe;assume (&;inits sample))
+ last (maybe;assume (&;last sample))]
(= sample
(append inits (list last)))))
diff --git a/stdlib/test/test/lux/data/coll/priority-queue.lux b/stdlib/test/test/lux/data/coll/priority-queue.lux
index d2fdb9969..51b9aee5e 100644
--- a/stdlib/test/test/lux/data/coll/priority-queue.lux
+++ b/stdlib/test/test/lux/data/coll/priority-queue.lux
@@ -3,7 +3,8 @@
(lux [io]
(control [monad #+ do Monad])
(data (coll ["&" priority-queue])
- [number])
+ [number]
+ [maybe])
["R" math/random])
lux/test)
@@ -42,8 +43,8 @@
(or (n.= +0 (&;size sample))
(and (&;member? number;Eq<Nat>
sample
- (default (undefined) (&;peek sample)))
+ (maybe;assume (&;peek sample)))
(not (&;member? number;Eq<Nat>
(&;pop sample)
- (default (undefined) (&;peek sample))))))))
+ (maybe;assume (&;peek sample))))))))
))
diff --git a/stdlib/test/test/lux/data/coll/stack.lux b/stdlib/test/test/lux/data/coll/stack.lux
index 60fb1a4bd..981d73197 100644
--- a/stdlib/test/test/lux/data/coll/stack.lux
+++ b/stdlib/test/test/lux/data/coll/stack.lux
@@ -4,7 +4,8 @@
(control [monad #+ do Monad])
(data (coll ["&" stack]
[list "" Fold<List>])
- [number])
+ [number]
+ [maybe])
["R" math/random])
lux/test)
@@ -37,6 +38,6 @@
(and (is sample
(&;pop (&;push new-top sample)))
(n.= (n.inc (&;size sample)) (&;size (&;push new-top sample)))
- (|> (&;push new-top sample) &;peek (default (undefined))
+ (|> (&;push new-top sample) &;peek maybe;assume
(is new-top))))
))
diff --git a/stdlib/test/test/lux/data/coll/stream.lux b/stdlib/test/test/lux/data/coll/stream.lux
index 0dfc03ed2..053228278 100644
--- a/stdlib/test/test/lux/data/coll/stream.lux
+++ b/stdlib/test/test/lux/data/coll/stream.lux
@@ -4,7 +4,8 @@
(control [monad #+ do Monad]
comonad
[cont])
- (data [text "Text/" Monoid<Text>]
+ (data [maybe]
+ [text "Text/" Monoid<Text>]
text/format
(coll [list]
["&" stream])
@@ -91,9 +92,9 @@
(test "Can cycle over the same elements as an infinite stream."
(|> (&;cycle cycle-seed)
- (default (undefined))
+ maybe;assume
(&;nth cycle-sample-idx)
- (n.= (default (undefined)
- (list;nth (n.% size cycle-sample-idx)
- cycle-seed)))))
+ (n.= (|> cycle-seed
+ (list;nth (n.% size cycle-sample-idx))
+ maybe;assume))))
))
diff --git a/stdlib/test/test/lux/data/coll/tree/zipper.lux b/stdlib/test/test/lux/data/coll/tree/zipper.lux
index 9154459b9..a65292cf0 100644
--- a/stdlib/test/test/lux/data/coll/tree/zipper.lux
+++ b/stdlib/test/test/lux/data/coll/tree/zipper.lux
@@ -8,7 +8,8 @@
[rose]))
[text]
text/format
- [number])
+ [number]
+ [maybe])
["r" math/random])
lux/test)
@@ -76,9 +77,9 @@
zipper (|> zipper
&;down
(&;insert-left pre-val)
- (default (undefined))
+ maybe;assume
(&;insert-right post-val)
- (default (undefined))
+ maybe;assume
&;up)]
(and (|> zipper &;down &;value (is pre-val))
(|> zipper &;down &;right &;value (is mid-val))
diff --git a/stdlib/test/test/lux/data/coll/vector.lux b/stdlib/test/test/lux/data/coll/vector.lux
index f197b8f10..2d7d00576 100644
--- a/stdlib/test/test/lux/data/coll/vector.lux
+++ b/stdlib/test/test/lux/data/coll/vector.lux
@@ -6,7 +6,8 @@
[list "List/" Fold<List> Functor<List>])
[text "Text/" Monoid<Text>]
text/format
- [number])
+ [number]
+ [maybe])
["R" math/random])
lux/test)
@@ -35,13 +36,13 @@
(|> sample
(&;put idx non-member)
(&;nth idx)
- (default (undefined))
+ maybe;assume
(is non-member)))
(test "Can update elements of vectors."
(|> sample
(&;put idx non-member) (&;update idx n.inc)
- (&;nth idx) (default (undefined))
+ (&;nth idx) maybe;assume
(n.= (n.inc non-member))))
(test "Can safely transform to/from lists."
diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux
index 382659ab0..b43aee394 100644
--- a/stdlib/test/test/lux/data/format/xml.lux
+++ b/stdlib/test/test/lux/data/format/xml.lux
@@ -8,6 +8,7 @@
text/format
[ident]
["R" result]
+ [maybe]
(format ["&" xml])
(coll [dict]
[list "L/" Functor<List>]))
@@ -25,7 +26,7 @@
(r;Random Nat)
(do r;Monad<Random>
[idx (|> r;nat (:: @ map (n.% (text;size char-range))))]
- (wrap (assume (text;nth idx char-range)))))
+ (wrap (maybe;assume (text;nth idx char-range)))))
(def: (size^ bottom top)
(-> Nat Nat (r;Random Nat))
diff --git a/stdlib/test/test/lux/type.lux b/stdlib/test/test/lux/type.lux
index 3e50f2035..8c149e3f4 100644
--- a/stdlib/test/test/lux/type.lux
+++ b/stdlib/test/test/lux/type.lux
@@ -6,7 +6,7 @@
(data [text "Text/" Monoid<Text>]
text/format
[number]
- maybe
+ [maybe]
(coll [list]))
["R" math/random]
["&" type])
@@ -51,8 +51,8 @@
(context: "Type application"
(test "Can apply quantified types (universal and existential quantification)."
- (and (default false
- (do Monad<Maybe>
+ (and (maybe;default false
+ (do maybe;Monad<Maybe>
[partial (&;apply (list Bool) Meta)
full (&;apply (list Int) partial)]
(wrap (:: &;Eq<Type> = full (#;Product Bool Int)))))