]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/unique/unique-tests.factor
io.files: exists? -> file-exists? and rename primitive.
[factor.git] / basis / io / files / unique / unique-tests.factor
1 USING: accessors continuations io.directories io.encodings.ascii
2 io.files io.files.info io.files.temp io.files.unique
3 io.pathnames kernel namespaces sequences strings tools.test ;
4
5 { 123 } [
6     [
7         "core" ".test" [
8             [ [ 123 CHAR: a <string> ] dip ascii set-file-contents ]
9             [ file-info size>> ] bi
10         ] cleanup-unique-file
11     ] with-temp-directory
12 ] unit-test
13
14 { t } [
15     [
16         current-directory get
17         [ [ "FAILDOG" throw ] cleanup-unique-directory ] ignore-errors
18         current-directory get =
19     ] with-temp-directory
20 ] unit-test
21
22 { t } [
23     [
24         [
25             "asdf" "" unique-file drop
26             "asdf2" "" unique-file drop
27             "." directory-files length 2 =
28         ] cleanup-unique-directory
29     ] with-temp-directory
30 ] unit-test
31
32 { t } [
33     [
34         [ ] with-unique-directory
35         [ file-exists? ] [ delete-tree ] bi
36     ] with-temp-directory
37 ] unit-test
38
39 { t } [
40     [
41         [
42             "asdf" "" unique-file drop
43             "asdf" "" unique-file drop
44             "." directory-files length 2 =
45         ] with-unique-directory drop
46     ] with-temp-directory
47 ] unit-test
48
49 { 29 } [
50     [
51         "unique-files-" { "-test.0" "-test.1" } [
52             [ file-name ] map first2 mismatch
53         ] cleanup-unique-files
54     ] with-temp-directory
55 ] unit-test