]> gitweb.factorcode.org Git - factor.git/commitdiff
io.files: Ensure that slices can be written to utf8/utf16/ascii streams.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 7 Apr 2016 19:42:52 +0000 (12:42 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 7 Apr 2016 19:42:52 +0000 (12:42 -0700)
core/io/files/files-tests.factor

index dc0fca30de433c2e07d0fc51dcf047a218e85256..ee8040f4e127c9cf216a6c2bc710194126181efc 100644 (file)
@@ -1,9 +1,10 @@
 USING: alien alien.c-types alien.data arrays classes.struct
 compiler.units continuations destructors fry generic.single io
 io.directories io.encodings.8-bit.latin1 io.encodings.ascii
-io.encodings.binary io.encodings.string io.files
-io.files.private io.pathnames kernel locals make math sequences
-specialized-arrays system threads tools.test vocabs ;
+io.encodings.binary io.encodings.string io.encodings.utf16
+io.encodings.utf8 io.files io.files.private io.pathnames kernel
+locals make math sequences specialized-arrays system threads
+tools.test vocabs ;
 FROM: specialized-arrays.private => specialized-array-vocab ;
 IN: io.files.tests
 
@@ -270,3 +271,24 @@ CONSTANT: pt-array-1
         [ cwd = ] [ cd ] [ cwd = ] tri
     ] cwd '[ _ dup cd cwd = ] [ ] cleanup
 ] unit-test
+
+{ t } [
+    [
+        [ 0 1 "å" <slice> swap utf8 set-file-contents ]
+        [ utf8 file-contents ] bi "å" =
+    ] with-test-file
+] unit-test
+
+{ t } [
+    [
+        [ 0 1 "å" <slice> swap utf16 set-file-contents ]
+        [ utf16 file-contents ] bi "å" =
+    ] with-test-file
+] unit-test
+
+{ t } [
+    [
+        [ 0 1 "a" <slice> swap ascii set-file-contents ]
+        [ ascii file-contents ] bi "a" =
+    ] with-test-file
+] unit-test