]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/io/ports/ports-tests.factor
Slices over specialized arrays can now be passed to C functions, written to binary...
[factor.git] / basis / io / ports / ports-tests.factor
index 7d8c799017c7dfaf5c7a3b21a2ca2edfdb6fbf04..c7af6909e16dd7fbe187129a73315ba0fae37aa0 100644 (file)
@@ -1,7 +1,6 @@
-USING: destructors io io.encodings.binary io.files io.directories
-io.files.temp io.ports kernel sequences math
-specialized-arrays.instances.alien.c-types.int tools.test
-specialized-arrays alien.c-types classes.struct alien ;
+USING: destructors io io.directories io.encodings.binary
+io.files io.files.temp kernel libc math sequences
+specialized-arrays.instances.alien.c-types.int tools.test ;
 IN: io.ports.tests
 
 ! Make sure that writing malloced storage to a file works, and
@@ -9,9 +8,11 @@ IN: io.ports.tests
 
 [ ] [
     "test.txt" temp-file binary [
-        100,000 iota
-        0
-        100,000 malloc-int-array &dispose [ copy ] keep write
+        [
+            100,000 iota
+            0
+            100,000 malloc-int-array &free [ copy ] keep write
+        ] with-destructors
     ] with-file-writer
 ] unit-test
 
@@ -21,43 +22,4 @@ IN: io.ports.tests
     ] with-file-reader
 ] unit-test
 
-USE: multiline
-/*
-[ ] [
-    BV{ 0 1 2 } "test.txt" temp-file binary set-file-contents
-] unit-test
-
-[ t ] [
-    "test.txt" temp-file binary file-contents
-    B{ 0 1 2 } =
-] unit-test
-
-STRUCT: pt { x uint } { y uint } ;
-SPECIALIZED-ARRAY: pt
-
-CONSTANT: pt-array-1
-    pt-array{ S{ pt f 1 1 } S{ pt f 2 2 } S{ pt f 3 3 } }
-
-[ ] [
-    pt-array-1
-    "test.txt" temp-file binary set-file-contents
-] unit-test
-
-[ t ] [
-    "test.txt" temp-file binary file-contents
-    pt-array-1 >c-ptr sequence=
-] unit-test
-
-[ ] [
-    pt-array-1 rest-slice 
-    "test.txt" temp-file binary set-file-contents
-] unit-test
-
-[ t ] [
-    "test.txt" temp-file binary file-contents
-    pt-array-1 rest-slice >c-ptr sequence=
-] unit-test
-
-*/
-
 [ ] [ "test.txt" temp-file delete-file ] unit-test