Issue Details (XML | Word | Printable)

Key: JRUBY-1470
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Charles Oliver Nutter
Reporter: Dudley Flanders
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

FileTest methods only work with string arguments

Created: 24/Oct/07 03:21 PM   Updated: 21/Mar/09 01:14 PM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.1.1
Fix Version/s: JRuby 1.2

Time Tracking:
Not Specified

File Attachments: 1. File filetest_file_arg.diff (1 kB)


Testcase included: yes


 Description  « Hide
FileTest methods in MRI work on filename strings or File objects, but in JRuby they only work with strings.
dudley@hiro jruby-trunk :> irb
>> FileTest.size(File.new('x','w+'))
=> 0

dudley@hiro jruby-trunk :> jirb
>> FileTest.size(File.new('x','w+'))
TypeError: can't convert File into String


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dudley Flanders added a comment - 25/Oct/07 02:09 PM
Here's a patch that works for the specific case where you're passing in a File object (or anything that responds_to "path"). MRI calls to_io and then fstat on the IO object's file descriptor, so this isn't 100% compatible, but it is slightly closer than just accepting strings.

Charles Oliver Nutter added a comment - 12/May/08 03:50 PM
Confirmed, this is still broken. I think the approach we need is to add specs for where to_io is supposed to be called to the rubyspecs and fix from there. No one-shot hacks, sorry

Marking as broken in 1.1.1 to keep it fresh.


Charles Oliver Nutter added a comment - 04/Feb/09 05:28 AM
Fixed in r8997. Also added some specs to RubySpec for at least File.size.