remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices
[factor/jcg.git] / core / io / files / files-tests.factor
blobf9702fd1337a993f460a29f0d6d73b8ecdf42696
1 USING: tools.test io.files io.files.private io.files.temp
2 io.directories io.encodings.8-bit arrays make system
3 io.encodings.binary io threads kernel continuations
4 io.encodings.ascii sequences strings accessors
5 io.encodings.utf8 math destructors namespaces ;
6 IN: io.files.tests
8 \ exists? must-infer
9 \ (exists?) must-infer
11 [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
13 [ ] [ "append-test" temp-file ascii <file-appender> dispose ] unit-test
16     "This is a line.\rThis is another line.\r"
17 ] [
18     "resource:core/io/test/mac-os-eol.txt" latin1 <file-reader>
19     [ 500 read ] with-input-stream
20 ] unit-test
23     255
24 ] [
25     "resource:core/io/test/binary.txt" latin1 <file-reader>
26     [ read1 ] with-input-stream >fixnum
27 ] unit-test
29 [ ] [
30     "It seems Jobs has lost his grasp on reality again.\n"
31     "separator-test.txt" temp-file latin1 set-file-contents
32 ] unit-test
35     {
36         { "It seems " CHAR: J }
37         { "obs has lost h" CHAR: i }
38         { "s grasp on reality again.\n" f }
39     }
40 ] [
41     [
42         "separator-test.txt" temp-file
43         latin1 <file-reader> [
44             "J" read-until 2array ,
45             "i" read-until 2array ,
46             "X" read-until 2array ,
47         ] with-input-stream
48     ] { } make
49 ] unit-test
51 [ ] [
52     image binary [
53         10 [ 65536 read drop ] times
54     ] with-file-reader
55 ] unit-test
57 ! Test EOF behavior
58 [ 10 ] [
59     image binary [
60         0 read drop
61         10 read length
62     ] with-file-reader
63 ] unit-test
65 USE: debugger.threads
67 [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test
69 [ ] [ "test-quux.txt" temp-file delete-file ] unit-test
71 [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test
73 [ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test
75 [ t ] [ "quux-test.txt" temp-file exists? ] unit-test
77 [ ] [ "quux-test.txt" temp-file delete-file ] unit-test