2008-04-11 08:15:26 -04:00
|
|
|
USING: accessors math kernel namespaces continuations
|
|
|
|
io.files io.monitors io.monitors.recursive io.backend
|
2008-12-15 04:33:04 -05:00
|
|
|
concurrency.mailboxes tools.test destructors io.files.info
|
2013-07-16 17:30:38 -04:00
|
|
|
io.pathnames io.files.temp io.directories.hierarchy fry ;
|
2008-04-11 08:15:26 -04:00
|
|
|
IN: io.monitors.recursive.tests
|
|
|
|
|
|
|
|
SINGLETON: mock-io-backend
|
|
|
|
|
2013-07-16 17:30:38 -04:00
|
|
|
TUPLE: mock-counter i ;
|
2008-04-11 08:15:26 -04:00
|
|
|
|
|
|
|
SYMBOL: dummy-monitor-created
|
|
|
|
SYMBOL: dummy-monitor-disposed
|
|
|
|
|
|
|
|
TUPLE: dummy-monitor < monitor ;
|
|
|
|
|
2013-07-16 17:30:38 -04:00
|
|
|
M: dummy-monitor dispose*
|
2009-08-13 20:21:44 -04:00
|
|
|
drop dummy-monitor-disposed get [ 1 + ] change-i drop ;
|
2008-04-11 08:15:26 -04:00
|
|
|
|
|
|
|
M: mock-io-backend (monitor)
|
|
|
|
nip
|
|
|
|
over exists? [
|
2008-04-14 06:07:31 -04:00
|
|
|
dummy-monitor new-monitor
|
2009-08-13 20:21:44 -04:00
|
|
|
dummy-monitor-created get [ 1 + ] change-i drop
|
2008-04-11 08:15:26 -04:00
|
|
|
] [
|
|
|
|
"Does not exist" throw
|
|
|
|
] if ;
|
|
|
|
|
|
|
|
M: mock-io-backend link-info
|
2012-07-19 03:02:47 -04:00
|
|
|
global [ link-info ] with-variables ;
|
2008-04-11 08:15:26 -04:00
|
|
|
|
2013-07-16 17:30:38 -04:00
|
|
|
[ ] [ 0 mock-counter boa dummy-monitor-created set ] unit-test
|
|
|
|
[ ] [ 0 mock-counter boa dummy-monitor-disposed set ] unit-test
|
2008-04-11 08:15:26 -04:00
|
|
|
|
|
|
|
[ ] [
|
|
|
|
mock-io-backend io-backend [
|
|
|
|
"" resource-path <mailbox> <recursive-monitor> dispose
|
|
|
|
] with-variable
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ t ] [ dummy-monitor-created get i>> 0 > ] unit-test
|
|
|
|
|
|
|
|
[ t ] [ dummy-monitor-created get i>> dummy-monitor-disposed get i>> = ] unit-test
|
|
|
|
|
|
|
|
[ "doesnotexist" temp-file delete-tree ] ignore-errors
|
|
|
|
|
|
|
|
[
|
2013-07-16 17:30:38 -04:00
|
|
|
0 mock-counter boa dummy-monitor-created [
|
|
|
|
mock-io-backend io-backend [
|
|
|
|
"doesnotexist" temp-file <mailbox> <recursive-monitor> dispose
|
|
|
|
] with-variable
|
2008-04-11 08:15:26 -04:00
|
|
|
] with-variable
|
|
|
|
] must-fail
|
|
|
|
|
2013-07-16 17:30:38 -04:00
|
|
|
[ ] [ 0 mock-counter boa dummy-monitor-created set ] unit-test
|
|
|
|
[ ] [ 0 mock-counter boa dummy-monitor-disposed set ] unit-test
|
|
|
|
|
|
|
|
! Test that disposing twice is allowed
|
2008-04-11 08:15:26 -04:00
|
|
|
[ ] [
|
2013-07-16 17:30:38 -04:00
|
|
|
"" resource-path <mailbox> <recursive-monitor>
|
|
|
|
[ dispose ] [ dispose ] bi
|
2008-04-11 08:15:26 -04:00
|
|
|
] unit-test
|