hashtables: fix the error thrown by H{ 1 }.
parent
0c22382c98
commit
52a9dfb11a
|
@ -1,5 +1,5 @@
|
|||
USING: accessors assocs continuations fry hashtables kernel make
|
||||
math namespaces sequences tools.test ;
|
||||
math namespaces sequences tools.test eval ;
|
||||
|
||||
{ H{ } } [ { } [ dup ] H{ } map>assoc ] unit-test
|
||||
|
||||
|
@ -125,6 +125,9 @@ H{ } "x" set
|
|||
! non-integer capacity not allowed
|
||||
[ 0.75 <hashtable> ] must-fail
|
||||
|
||||
[ "H{ 1 }" eval( str -- obj ) ] must-fail
|
||||
[ "H{ 1 2 -- 3 }" eval( str -- obj ) ] must-fail
|
||||
|
||||
! Another crash discovered by erg
|
||||
{ } [
|
||||
H{ } clone
|
||||
|
|
|
@ -194,7 +194,13 @@ M: hashtable assoc-like
|
|||
ERROR: malformed-hashtable-pair seq pair ;
|
||||
|
||||
: check-hashtable ( seq -- seq )
|
||||
dup [ dup length 2 = [ drop ] [ malformed-hashtable-pair ] if ] each ;
|
||||
dup [
|
||||
dup sequence? [
|
||||
dup length 2 = [ drop ] [ malformed-hashtable-pair ] if
|
||||
] [
|
||||
malformed-hashtable-pair
|
||||
] if
|
||||
] each ;
|
||||
|
||||
: parse-hashtable ( seq -- hashtable )
|
||||
check-hashtable H{ } assoc-clone-like ;
|
||||
|
|
Loading…
Reference in New Issue