aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test/test/lux/data/coll/dict.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux/data/coll/dict.lux36
1 files changed, 18 insertions, 18 deletions
diff --git a/stdlib/test/test/lux/data/coll/dict.lux b/stdlib/test/test/lux/data/coll/dict.lux
index ddc1ddd2d..4f1b94478 100644
--- a/stdlib/test/test/lux/data/coll/dict.lux
+++ b/stdlib/test/test/lux/data/coll/dict.lux
@@ -15,17 +15,17 @@
(context: "Dictionaries."
(<| (times +100)
(do @
- [#let [capped-nat (:: r;Monad<Random> map (n.% +100) r;nat)]
+ [#let [capped-nat (:: r;Monad<Random> map (n/% +100) r;nat)]
size capped-nat
dict (r;dict number;Hash<Nat> size r;nat capped-nat)
non-key (|> r;nat (r;filter (function [key] (not (&;contains? key dict)))))
test-val (|> r;nat (r;filter (function [val] (not (list;member? number;Eq<Nat> (&;values dict) val)))))]
($_ seq
(test "Size function should correctly represent Dict size."
- (n.= size (&;size dict)))
+ (n/= size (&;size dict)))
(test "Dicts of size 0 should be considered empty."
- (if (n.= +0 size)
+ (if (n/= +0 size)
(&;empty? dict)
(not (&;empty? dict))))
@@ -52,19 +52,19 @@
(test "Should be able to put and then get a value."
(case (&;get non-key (&;put non-key test-val dict))
- (#;Some v) (n.= test-val v)
+ (#;Some v) (n/= test-val v)
_ true))
(test "Should be able to put~ and then get a value."
(case (&;get non-key (&;put~ non-key test-val dict))
- (#;Some v) (n.= test-val v)
+ (#;Some v) (n/= test-val v)
_ true))
(test "Shouldn't be able to put~ an existing key."
- (or (n.= +0 size)
+ (or (n/= +0 size)
(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))
+ (#;Some v) (not (n/= test-val v))
_ true))))
(test "Removing a key should make it's value inaccessible."
@@ -74,10 +74,10 @@
(test "Should be possible to update values via their keys."
(let [base (&;put non-key test-val dict)
- updt (&;update non-key n.inc base)]
+ updt (&;update non-key n/inc base)]
(case [(&;get non-key base) (&;get non-key updt)]
[(#;Some x) (#;Some y)]
- (n.= (n.inc x) y)
+ (n/= (n/inc x) y)
_
false)))
@@ -85,8 +85,8 @@
(test "Additions and removals to a Dict should affect its size."
(let [plus (&;put non-key test-val dict)
base (&;remove non-key plus)]
- (and (n.= (n.inc (&;size dict)) (&;size plus))
- (n.= (n.dec (&;size plus)) (&;size base)))))
+ (and (n/= (n/inc (&;size dict)) (&;size plus))
+ (n/= (n/dec (&;size plus)) (&;size base)))))
(test "A Dict should equal itself & going to<->from lists shouldn't change that."
(let [(^open) (&;Eq<Dict> number;Eq<Nat>)]
@@ -99,30 +99,30 @@
(test "If you merge, and the second dict has overlapping keys, it should overwrite yours."
(let [dict' (|> dict &;entries
- (list/map (function [[k v]] [k (n.inc v)]))
+ (list/map (function [[k v]] [k (n/inc v)]))
(&;from-list number;Hash<Nat>))
(^open) (&;Eq<Dict> number;Eq<Nat>)]
(= dict' (&;merge dict' dict))))
(test "Can merge values in such a way that they become combined."
- (list;every? (function [[x x*2]] (n.= (n.* +2 x) x*2))
+ (list;every? (function [[x x*2]] (n/= (n/* +2 x) x*2))
(list;zip2 (&;values dict)
- (&;values (&;merge-with n.+ dict dict)))))
+ (&;values (&;merge-with n/+ dict dict)))))
(test "Should be able to select subset of keys from dict."
(|> dict
(&;put non-key test-val)
(&;select (list non-key))
&;size
- (n.= +1)))
+ (n/= +1)))
(test "Should be able to re-bind existing values to different keys."
- (or (n.= +0 size)
+ (or (n/= +0 size)
(let [first-key (|> dict &;keys list;head maybe;assume)
rebound (&;re-bind first-key non-key dict)]
- (and (n.= (&;size dict) (&;size rebound))
+ (and (n/= (&;size dict) (&;size rebound))
(&;contains? non-key rebound)
(not (&;contains? first-key rebound))
- (n.= (maybe;assume (&;get first-key dict))
+ (n/= (maybe;assume (&;get first-key dict))
(maybe;assume (&;get non-key rebound)))))))
))))