M: array clone (clone) ; inline
M: array length length>> ; inline
-M: array nth-unsafe [ >fixnum ] dip array-nth ; inline
-M: array set-nth-unsafe [ >fixnum ] dip set-array-nth ; inline
+M: array nth-unsafe [ integer>fixnum ] dip array-nth ; inline
+M: array set-nth-unsafe [ integer>fixnum ] dip set-array-nth ; inline
M: array resize resize-array ; inline
M: array equal? over array? [ sequence= ] [ 2drop f ] if ;
M: object new-sequence drop 0 <array> ; inline
USING: arrays byte-arrays kernel math math.order math.parser
namespaces sequences kernel.private sequences.private strings
-sbufs tools.test vectors assocs generic vocabs.loader ;
+sbufs tools.test vectors assocs generic vocabs.loader
+generic.single ;
IN: sequences.tests
[ "empty" ] [ { } [ "empty" ] [ "not empty" ] if-empty ] unit-test
[ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] bi@ ] unit-test
-[ 1 ] [ 0.5 { 1 2 3 } nth ] unit-test
+[ 0.5 10 iota nth ] [ no-method? ] must-fail-with
+[ 0.5 { 1 2 3 } nth ] [ no-method? ] must-fail-with
+[ 0.5 "asdfasdf" nth ] [ no-method? ] must-fail-with
! Pathological case
[ "ihbye" ] [ "hi" <reversed> "bye" append ] unit-test
: iota ( n -- iota ) \ iota boa ; inline
M: iota length n>> ; inline
-M: iota nth-unsafe drop ; inline
+M: iota nth-unsafe drop integer>fixnum ; inline
INSTANCE: iota immutable-sequence
<PRIVATE
: sequence-hashcode-step ( oldhash newpart -- newhash )
- >fixnum swap [
+ integer>fixnum swap [
[ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi
fixnum+fast fixnum+fast
] keep fixnum-bitxor ; inline
#! We can't use case here since combinators depends on
#! sequences
pick length dup 0 3 between? [
- >fixnum {
+ integer>fixnum {
[ drop nip ]
[ 2drop first ]
[ [ drop first2 ] dip call ]
length>> ; inline
M: string nth-unsafe
- [ >fixnum ] dip string-nth ; inline
+ [ integer>fixnum ] dip string-nth ; inline
M: string set-nth-unsafe
dup reset-string-hashcode
- [ >fixnum ] [ >fixnum ] [ ] tri* set-string-nth ; inline
+ [ integer>fixnum ] [ integer>fixnum ] [ ] tri* set-string-nth ; inline
M: string clone
(clone) [ clone ] change-aux ; inline
] unless ; inline
M: vector new-sequence
- drop [ f <array> ] [ >fixnum ] bi vector boa ; inline
+ drop [ f <array> ] [ integer>fixnum ] bi vector boa ; inline
M: vector equal?
over vector? [ sequence= ] [ 2drop f ] if ;