[macruby-changes] [MacRuby/MacRuby] 37bf49: IO.readlines (and family) will raise a TypeError w...
noreply at github.com
noreply at github.com
Thu May 12 22:24:22 PDT 2011
Branch: refs/heads/master
Home: https://github.com/MacRuby/MacRuby
Commit: 37bf494f082e41b4bb75c4de697a6653aea76acf
https://github.com/MacRuby/MacRuby/commit/37bf494f082e41b4bb75c4de697a6653aea76acf
Author: Watson <watson1978 at gmail.com>
Date: 2011-05-12 (Thu, 12 May 2011)
Changed paths:
M io.c
Log Message:
-----------
IO.readlines (and family) will raise a TypeError when was passed Object which has not to_str method.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
File.open("/tmp/foo", "w") {|f|
f.puts "foo"
f.puts "bar"
}
sep = Object.new
assert_raise(TypeError){ IO.readlines("/tmp/foo", sep, 10) }
assert_raise(TypeError){ IO.readlines("/tmp/foo", sep) }
def sep.to_str; "\n"; end
ary = IO.readlines("/tmp/foo", sep, 10)
assert_equal(["foo\n", "bar\n"], ary)
ary = IO.readlines("/tmp/foo", sep)
assert_equal(["foo\n", "bar\n"], ary)
ary = IO.readlines("/tmp/foo", 10)
assert_equal(["foo\n", "bar\n"], ary)
puts :ok
}}}
More information about the macruby-changes
mailing list