ruby-changes:71739
From: Nobuyoshi <ko1@a...>
Date: Fri, 15 Apr 2022 17:14:47 +0900 (JST)
Subject: [ruby-changes:71739] 9db7d95968 (master): Compare predicate methods as a boolean value
https://git.ruby-lang.org/ruby.git/commit/?id=9db7d95968 From 9db7d95968a832dd095eccf9cfe29255ac15b2c2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 15 Apr 2022 11:17:22 +0900 Subject: Compare predicate methods as a boolean value --- test/ruby/test_file_exhaustive.rb | 42 +++++++++++++++++++++------------------ 1 file 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1516 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1788 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/