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