[macruby-changes] [MacRuby/MacRuby] 7945ac: IO#reopen will accept an object that has a #to_pat...

noreply at github.com noreply at github.com
Tue Mar 29 07:16:15 PDT 2011


Branch: refs/heads/master
Home:   https://github.com/MacRuby/MacRuby

Commit: 7945aca523c6dc638a252d5c7941d7f41cdea933
    https://github.com/MacRuby/MacRuby/commit/7945aca523c6dc638a252d5c7941d7f41cdea933
Author: Watson <watson1978 at gmail.com>
Date:   2011-03-29 (Tue, 29 Mar 2011)

Changed paths:
  M io.c
  M spec/frozen/tags/macruby/core/file/reopen_tags.txt
  M spec/frozen/tags/macruby/core/io/reopen_tags.txt

Log Message:
-----------
IO#reopen will accept an object that has a #to_path method.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

FILE1 = "tmp.xxxxxx"
FILE2 = "tmp.reopen.xxxxx"

io = File.open(FILE1, "w")

obj = Object.new
def obj.to_path
  FILE2
end

io.reopen(obj, "w")
io.puts "hello world"
io.close

File.open(FILE2, "r") { |f|
  assert_equal("hello world\n", f.gets)
}

File.unlink(FILE1)
File.unlink(FILE2)

puts :ok
}}}




More information about the macruby-changes mailing list