From e19937939e6ec7f86c59fa3de1db0fa7fa1cdc98 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 20 May 2024 23:53:55 -0600 Subject: [PATCH] test: {when,if,unless}-file-exists Signed-off-by: Rudi Grinberg --- core/io/files/files-tests.factor | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index 3eed33dce38..92994ac5ec6 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -303,3 +303,26 @@ CONSTANT: pt-array-1 ] unit-test { f } [ f file-exists? ] unit-test + +{ } [ + "should-never-exist" [ drop t ] when-file-exists +] unit-test + +{ t } [ + [ [ drop t ] when-file-exists ] with-test-file +] unit-test + +{ t } [ + "should-never-exist" [ drop t ] unless-file-exists +] unit-test + +{ } [ + [ [ drop t ] unless-file-exists ] with-test-file +] unit-test + +: ife-bool ( path -- bool ) + [ drop t ] [ drop f ] if-file-exists ; + +{ t } [ [ ife-bool ] with-test-file ] unit-test + +{ f } [ "should-never-exist" ife-bool ] unit-test