1 USING: accessors calendar concurrency.count-downs
2 concurrency.promises continuations destructors io io.directories
3 io.files io.monitors io.pathnames io.timeouts kernel namespaces
4 sequences threads tools.test ;
8 { } [ "." t <monitor> "m" set ] unit-test
10 { } [ "a1" make-directory ] unit-test
11 { } [ "a2" make-directory ] unit-test
12 { } [ "a1" "a2" move-file-into ] unit-test
14 { t } [ "a2/a1" file-exists? ] unit-test
16 { } [ "a2/a1/a3.txt" touch-file ] unit-test
18 { t } [ "a2/a1/a3.txt" file-exists? ] unit-test
20 { } [ "a2/a1/a4.txt" touch-file ] unit-test
21 { } [ "a2/a1/a5.txt" touch-file ] unit-test
22 { } [ "a2/a1/a4.txt" delete-file ] unit-test
23 { } [ "a2/a1/a5.txt" "a2/a1/a4.txt" move-file ] unit-test
25 { t } [ "a2/a1/a4.txt" file-exists? ] unit-test
27 { } [ "m" get dispose ] unit-test
33 { } [ "xyz" make-directory ] unit-test
34 { } [ "." t <monitor> "m" set ] unit-test
36 { } [ 1 <count-down> "b" set ] unit-test
37 { } [ 1 <count-down> "c1" set ] unit-test
38 { } [ 1 <count-down> "c2" set ] unit-test
44 "m" get next-change path>>
47 [ trim-tail-separators "xyz" tail? ] either? not
52 "m" get next-change path>>
55 [ trim-tail-separators "yxy" tail? ] either? not
59 ] "Monitor test thread" spawn drop
61 { } [ "b" get await ] unit-test
62 { } [ "xyz/test.txt" touch-file ] unit-test
63 { } [ "c1" get 1 minutes await-timeout ] unit-test
64 { } [ "subdir/blah/yxy" make-directories ] unit-test
65 { } [ "subdir/blah/yxy/test.txt" touch-file ] unit-test
66 { } [ "c2" get 1 minutes await-timeout ] unit-test
69 { } [ "m" get dispose ] unit-test
70 { } [ "m" get dispose ] unit-test
74 ! Out-of-scope disposal should not fail
75 { } [ [ "resource:" f <monitor> ] with-monitors dispose ] unit-test
76 { } [ [ "resource:" t <monitor> ] with-monitors dispose ] unit-test
83 "." f <monitor> "m" set
84 100 milliseconds "m" get set-timeout
85 [ [ t ] [ "m" get next-change drop ] while ] must-fail
91 "." t <monitor> "m" set
92 100 milliseconds "m" get set-timeout
93 [ [ t ] [ "m" get next-change drop ] while ] must-fail
99 ! Disposing a monitor should throw an error in any threads
100 ! waiting on notifications
105 "." t <monitor> "m" set
106 10 seconds "m" get set-timeout
110 [ "m" get next-change ] [ ] recover
115 100 milliseconds sleep
120 "p" get 10 seconds ?promise-timeout
124 ] with-test-directory