]> gitweb.factorcode.org Git - factor.git/commitdiff
core: Use integer>fixnum instead of >fixnum for ``nth`` and other sequence operations...
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 26 Jul 2012 01:24:43 +0000 (18:24 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 26 Jul 2012 01:24:43 +0000 (18:24 -0700)
core/arrays/arrays.factor
core/sequences/sequences-tests.factor
core/sequences/sequences.factor
core/strings/strings.factor
core/vectors/vectors.factor

index 21f9c239fd94a72421ae7cb9304f8d0c4278a0cf..085a6a582be3e48a0cdf8d0b4faa6b10e219b3af 100644 (file)
@@ -5,8 +5,8 @@ IN: arrays
 
 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
index c1bc96c2590008b9967321643bb531a6043aa4a6..a4167bfcbda3d7fb5204dacb1cbe6287b61dfed8 100644 (file)
@@ -1,6 +1,7 @@
 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
@@ -213,7 +214,9 @@ 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
index 67e444030389c96c28e6dff0120276728254f4de..dd6774011e44dd52780c0fff8d348a375f66e5cb 100644 (file)
@@ -106,7 +106,7 @@ TUPLE: iota { n integer read-only } ;
 : 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
 
@@ -634,7 +634,7 @@ ERROR: assert-sequence got expected ;
 <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
@@ -845,7 +845,7 @@ PRIVATE>
     #! 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 ]
index 1f266e2e473076ef4b9e59c59c66aaee0cc685dc..f0e589b7db61ddf89b2aebc216eb950fa087676d 100644 (file)
@@ -63,11 +63,11 @@ M: string length
     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
index 4bbc787294b721c26265deb2c77c995e90ab9f64..e9def85fbb5b068f3147732dddab4a399d452ca1 100644 (file)
@@ -18,7 +18,7 @@ M: vector like
     ] 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 ;