]> gitweb.factorcode.org Git - factor.git/commitdiff
grouping: change chunking to throw bounds-errors in nth.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 6 Mar 2018 00:57:52 +0000 (16:57 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 6 Mar 2018 00:57:52 +0000 (16:57 -0800)
instead of the more confusing slice-error.

basis/grouping/grouping-tests.factor
basis/grouping/grouping.factor

index e2e222b6d637d14953bdf7c90136f5a4042808bd..0b9a24ea3eb9575b1d9fc5026dd45c5221f84530 100644 (file)
@@ -2,6 +2,7 @@ USING: grouping tools.test kernel sequences arrays
 math accessors ;
 
 [ { 1 2 3 } 0 group ] must-fail
+[ f 3 <groups> first ] [ bounds-error? ] must-fail-with
 
 { { "hell" "o wo" "rld" } } [ "hello world" 4 group ] unit-test
 
index 52fb0b74c26406255ef2b64f508ec0ed73deb7ea..e2309d9884d6cc90dfa79c831886778f88fc6ca5 100644 (file)
@@ -14,11 +14,9 @@ TUPLE: chunking { seq read-only } { n read-only } ;
 
 INSTANCE: chunking sequence
 
-M: chunking nth group@ <slice> ; inline
-
 M: chunking nth-unsafe group@ <slice-unsafe> ; inline
 
-M: chunking set-nth group@ <slice> 0 swap copy ;
+M: chunking set-nth-unsafe group@ <slice-unsafe> 0 swap copy ;
 
 M: chunking like drop { } like ; inline