]> gitweb.factorcode.org Git - factor.git/blobdiff - core/hashtables/hashtables-tests.factor
ui.listener: document that ~/.factor-history persists input history
[factor.git] / core / hashtables / hashtables-tests.factor
index f188b8610e652402318b152a0001785d17a371c2..96ae5f71a949d1aec30c55842244d4617b801854 100644 (file)
@@ -1,14 +1,12 @@
-USING: accessors assocs continuations hashtables io kernel make
-math namespaces prettyprint sequences sequences.private
-tools.test vectors ;
-IN: hashtables.tests
+USING: accessors assocs continuations hashtables kernel make
+math namespaces sequences tools.test ;
 
 { H{ } } [ { } [ dup ] H{ } map>assoc ] unit-test
 
-{ } [ 1000 iota [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
+{ } [ 1000 <iota> [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
 
 { V{ } }
-[ 1000 iota [ dup sq swap "testhash" get at = ] reject ]
+[ 1000 <iota> [ dup sq swap "testhash" get at = ] reject ]
 unit-test
 
 { t }
@@ -124,8 +122,8 @@ H{ } clone "counting" set
 H{ } "x" set
 100 [ drop "x" get clear-assoc ] each-integer
 
-! Crash discovered by erg
-{ t } [ 0.75 <hashtable> dup clone = ] unit-test
+! non-integer capacity not allowed
+[ 0.75 <hashtable> ] must-fail
 
 ! Another crash discovered by erg
 { } [
@@ -141,6 +139,14 @@ H{ } "x" set
     [ [ neg ] dip sq ] assoc-map
 ] unit-test
 
+! make sure growth and capacity use same load-factor
+{ t } [
+    100 <iota>
+    [ [ <hashtable> ] map ]
+    [ [ H{ } clone [ '[ dup _ set-at ] each-integer ] keep ] map ] bi
+    [ [ array>> length ] bi@ = ] 2all?
+] unit-test
+
 ! Bug discovered by littledan
 { { 5 5 5 5 } } [
     [
@@ -177,4 +183,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 of ] unit-test
+{ "A" } [ 100 <iota> [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 of ] unit-test