Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/RubyFileTest.java
Original file line number Diff line number Diff line change
@@ -197,8 +197,7 @@ public static IRubyObject readable_p(ThreadContext context, IRubyObject recv, IR
filename = get_path(context, filename);
}

FileStat stat = fileResource(filename).stat();
return runtime.newBoolean(stat != null && stat.isReadable());
return runtime.newBoolean(fileResource(filename).canRead());
}

// Not exposed by filetest, but so similiar in nature that it is stored here
8 changes: 8 additions & 0 deletions test/test_file.rb
Original file line number Diff line number Diff line change
@@ -484,6 +484,14 @@ def test_file_query # - file?
assert(result == 'falsefalsetrue')
end

def test_readable_query # - readable?
assert(File.readable?('test/test_file.rb'))
assert(File.readable?('test'))
assert(! File.readable?('test_not'))
result = jruby("-e 'print File.readable?(\"test_not\");print File.readable?(\"test\");print File.readable?(\"test/test_file.rb\")'", 'jruby.native.enabled' => 'false' )
assert(result == 'falsetruetrue')
end

def test_file_exist_query
assert(File.exist?('test'))
assert(! File.exist?('test_not'))

0 comments on commit 8a5ea5c

Please sign in to comment.