]> gitweb.factorcode.org Git - factor.git/blob - basis/io/mmap/mmap-tests.factor
mmap now throws an understandable exception upon trying to mmap a zero length file...
[factor.git] / basis / io / mmap / mmap-tests.factor
1 USING: io io.mmap io.mmap.char io.files io.files.temp
2 io.directories kernel tools.test continuations sequences
3 io.encodings.ascii accessors ;
4 IN: io.mmap.tests
5
6 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
7 [ ] [ "12345" "mmap-test-file.txt" temp-file ascii set-file-contents ] unit-test
8 [ ] [ "mmap-test-file.txt" temp-file [ CHAR: 2 0 pick set-nth drop ] with-mapped-char-file ] unit-test
9 [ 5 ] [ "mmap-test-file.txt" temp-file [ length ] with-mapped-char-file ] unit-test
10 [ "22345" ] [ "mmap-test-file.txt" temp-file ascii file-contents ] unit-test
11 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
12
13
14 [ ]
15 [ "mmap-empty-file.txt" temp-file touch-file ] unit-test
16
17 ! Test for leaking resources bug on Unix
18 [ ]
19 [
20     100000 [
21         [
22             "mmap-empty-file.txt" temp-file [
23                 drop
24             ] with-mapped-file
25         ] [ dup bad-mmap-size? [ drop ] [ rethrow ] if ] recover
26     ] times
27
28     "asdf" "mmap-asdf-file.txt" temp-file [ ascii set-file-contents ] keep [
29         drop
30     ] with-mapped-file
31 ] unit-test