]> gitweb.factorcode.org Git - factor.git/blobdiff - core/hashtables/hashtables-tests.factor
use reject instead of [ ... not ] filter.
[factor.git] / core / hashtables / hashtables-tests.factor
index 541f98ab9ca3ecbe00ac4c3996f84343568d0346..5a6ba05e9e52708a8d4a03a062785962bccef30f 100644 (file)
@@ -1,6 +1,6 @@
-USING: kernel math namespaces make tools.test vectors sequences
-sequences.private hashtables io prettyprint assocs
-continuations ;
+USING: accessors assocs continuations hashtables io kernel make
+math namespaces prettyprint sequences sequences.private
+tools.test vectors ;
 IN: hashtables.tests
 
 [ H{ } ] [ { } [ dup ] H{ } map>assoc ] unit-test
@@ -8,7 +8,7 @@ IN: hashtables.tests
 [ ] [ 1000 iota [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
 
 [ V{ } ]
-[ 1000 iota [ dup sq swap "testhash" get at = not ] filter ]
+[ 1000 iota [ dup sq swap "testhash" get at = ] reject ]
 unit-test
 
 [ t ]
@@ -19,6 +19,12 @@ unit-test
 [ { 1 { 2 3 } } hashtable? ]
 unit-test
 
+{ t } [
+    "value" "key"
+    [ associate ] [ H{ } clone [ set-at ] keep ] 2bi
+    [ = ] [ [ array>> length ] bi@ = ] 2bi and
+] unit-test
+
 ! Test some hashcodes.
 
 [ t ] [ [ 1 2 3 ] hashcode [ 1 2 3 ] hashcode = ] unit-test
@@ -171,4 +177,4 @@ H{ } "x" set
 [ 1 ] [ 2 "h" get at ] unit-test
 
 ! Random test case
-[ "A" ] [ 100 iota [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
+[ "A" ] [ 100 iota [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 of ] unit-test