1 USING: accessors math kernel namespaces continuations
2 io.files io.monitors io.monitors.recursive io.backend
3 concurrency.mailboxes tools.test destructors io.files.info
4 io.pathnames io.files.temp io.directories fry ;
5 IN: io.monitors.recursive.tests
7 SINGLETON: mock-io-backend
9 TUPLE: mock-counter i ;
11 SYMBOL: dummy-monitor-created
12 SYMBOL: dummy-monitor-disposed
14 TUPLE: dummy-monitor < monitor ;
16 M: dummy-monitor dispose*
17 drop dummy-monitor-disposed get [ 1 + ] change-i drop ;
19 M: mock-io-backend (monitor)
22 dummy-monitor new-monitor
23 dummy-monitor-created get [ 1 + ] change-i drop
25 "Does not exist" throw
28 M: mock-io-backend link-info
29 global [ link-info ] with-variables ;
31 { } [ 0 mock-counter boa dummy-monitor-created set ] unit-test
32 { } [ 0 mock-counter boa dummy-monitor-disposed set ] unit-test
35 mock-io-backend io-backend [
36 "resource:core/io" <mailbox> <recursive-monitor> dispose
40 { t } [ dummy-monitor-created get i>> 0 > ] unit-test
42 { t } [ dummy-monitor-created get i>> dummy-monitor-disposed get i>> = ] unit-test
44 [ "doesnotexist" temp-file delete-tree ] ignore-errors
47 0 mock-counter boa dummy-monitor-created [
48 mock-io-backend io-backend [
49 "doesnotexist" temp-file <mailbox> <recursive-monitor> dispose
54 { } [ 0 mock-counter boa dummy-monitor-created set ] unit-test
55 { } [ 0 mock-counter boa dummy-monitor-disposed set ] unit-test
57 ! Test that disposing twice is allowed
59 "resource:core/io" <mailbox> <recursive-monitor>
60 [ dispose ] [ dispose ] bi