diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-04-15 11:17:22 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-04-15 17:14:29 +0900 |
commit | 9db7d95968a832dd095eccf9cfe29255ac15b2c2 (patch) | |
tree | e710f4e1eaf453dd596ed92b625cc05387c20527 /test/ruby/test_file_exhaustive.rb | |
parent | a0040af6715d85f416f1282588974e151a8164eb (diff) | |
download | ruby-9db7d95968a832dd095eccf9cfe29255ac15b2c2.tar.gz |
Compare predicate methods as a boolean value
Diffstat (limited to 'test/ruby/test_file_exhaustive.rb')
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index d3916b25a2..579e4d77a9 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -1516,26 +1516,26 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(stat.atime, File.atime(f), f) assert_equal(stat.ctime, File.ctime(f), f) assert_equal(stat.mtime, File.mtime(f), f) - assert_equal(stat.blockdev?, File.blockdev?(f), f) - assert_equal(stat.chardev?, File.chardev?(f), f) - assert_equal(stat.directory?, File.directory?(f), f) - assert_equal(stat.file?, File.file?(f), f) - assert_equal(stat.setgid?, File.setgid?(f), f) - assert_equal(stat.grpowned?, File.grpowned?(f), f) - assert_equal(stat.sticky?, File.sticky?(f), f) - assert_equal(File.lstat(f).symlink?, File.symlink?(f), f) - assert_equal(stat.owned?, File.owned?(f), f) - assert_equal(stat.pipe?, File.pipe?(f), f) - assert_equal(stat.readable?, File.readable?(f), f) - assert_equal(stat.readable_real?, File.readable_real?(f), f) + assert_bool_equal(stat.blockdev?, File.blockdev?(f), f) + assert_bool_equal(stat.chardev?, File.chardev?(f), f) + assert_bool_equal(stat.directory?, File.directory?(f), f) + assert_bool_equal(stat.file?, File.file?(f), f) + assert_bool_equal(stat.setgid?, File.setgid?(f), f) + assert_bool_equal(stat.grpowned?, File.grpowned?(f), f) + assert_bool_equal(stat.sticky?, File.sticky?(f), f) + assert_bool_equal(File.lstat(f).symlink?, File.symlink?(f), f) + assert_bool_equal(stat.owned?, File.owned?(f), f) + assert_bool_equal(stat.pipe?, File.pipe?(f), f) + assert_bool_equal(stat.readable?, File.readable?(f), f) + assert_bool_equal(stat.readable_real?, File.readable_real?(f), f) assert_equal(stat.size?, File.size?(f), f) - assert_equal(stat.socket?, File.socket?(f), f) - assert_equal(stat.setuid?, File.setuid?(f), f) - assert_equal(stat.writable?, File.writable?(f), f) - assert_equal(stat.writable_real?, File.writable_real?(f), f) - assert_equal(stat.executable?, File.executable?(f), f) - assert_equal(stat.executable_real?, File.executable_real?(f), f) - assert_equal(stat.zero?, File.zero?(f), f) + assert_bool_equal(stat.socket?, File.socket?(f), f) + assert_bool_equal(stat.setuid?, File.setuid?(f), f) + assert_bool_equal(stat.writable?, File.writable?(f), f) + assert_bool_equal(stat.writable_real?, File.writable_real?(f), f) + assert_bool_equal(stat.executable?, File.executable?(f), f) + assert_bool_equal(stat.executable_real?, File.executable_real?(f), f) + assert_bool_equal(stat.zero?, File.zero?(f), f) end assert_equal(false, test(?-, @dir, fn1)) assert_equal(true, test(?-, fn1, fn1)) @@ -1788,4 +1788,8 @@ class TestFileExhaustive < Test::Unit::TestCase dir = File.expand_path("/bar") assert_equal(File.join(dir, "~foo"), File.absolute_path("~foo", dir)) end + + def assert_bool_equal(expected, result, *messages) + assert_equal(expected, true & result, *messages) + end end |