nibble-arrays: -1 <nibble-array> should throw an error

db4
Slava Pestov 2011-08-27 16:44:59 -07:00
parent 385a51b3ef
commit 48dfa97f97
2 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,8 @@
USING: nibble-arrays tools.test sequences kernel math ;
IN: nibble-arrays.tests
[ -1 <nibble-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
[ t ] [ 16 iota dup >nibble-array sequence= ] unit-test
[ N{ 4 2 1 3 } ] [ N{ 3 1 2 4 } reverse ] unit-test
[ N{ 1 4 9 0 9 4 } ] [ N{ 1 2 3 4 5 6 } [ sq ] map ] unit-test

View File

@ -30,7 +30,10 @@ CONSTANT: nibble BIN: 1111
PRIVATE>
ERROR: bad-array-length n ;
: <nibble-array> ( n -- nibble-array )
dup 0 < [ bad-array-length ] when
dup nibbles>bytes <byte-array> nibble-array boa ; inline
M: nibble-array length length>> ;