]> gitweb.factorcode.org Git - factor.git/commitdiff
struct-arrays: fix new-sequence method
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 3 Sep 2009 07:23:37 +0000 (02:23 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 3 Sep 2009 07:23:37 +0000 (02:23 -0500)
basis/struct-arrays/struct-arrays-tests.factor
basis/struct-arrays/struct-arrays.factor

index 0a79f47a345adab0b4bddfee2a4dd13381adeb83..3fbdeacd935ef8c6ce04ed091be2bdcd158b5032 100755 (executable)
@@ -1,11 +1,20 @@
 IN: struct-arrays.tests
 USING: classes.struct struct-arrays tools.test kernel math sequences
-alien.syntax alien.c-types destructors libc accessors sequences.private ;
+alien.syntax alien.c-types destructors libc accessors sequences.private
+compiler.tree.debugger combinators.smart ;
 
 STRUCT: test-struct-array
     { x int }
     { y int } ;
 
+[ 1 ] [
+    1 struct-array{ test-struct-array } new-sequence length
+] unit-test
+
+[ V{ test-struct-array } ] [
+    [ [ test-struct-array <struct> ] struct-array{ test-struct-array } output>sequence first ] final-classes
+] unit-test
+
 : make-point ( x y -- struct )
     test-struct-array <struct-boa> ;
 
index 15f996f3bf0a43ff0377ce474343327659956cad..c5780826027fac9cc013fd0b6638ede5baafc4d9 100755 (executable)
@@ -48,7 +48,7 @@ ERROR: not-a-struct-class struct-class ;
     tri struct-array boa ; inline
 
 M: struct-array new-sequence
-    [ element-size>> * (byte-array) ] [ length>> ] [ class>> ] tri
+    [ element-size>> * (byte-array) ] [ class>> ] 2bi
     <direct-struct-array> ; inline
 
 M: struct-array resize ( n seq -- newseq )