Skip to content

Commit

Permalink
test: {when,if,unless}-file-exists
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored and mrjbq7 committed May 23, 2024
1 parent b16eed9 commit e199379
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/io/files/files-tests.factor
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e199379

Please sign in to comment.