diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-11 21:42:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-11 21:42:40 +0000 |
commit | c8726d8ed923ed867a89f55d39f45ff43aa06ff6 (patch) | |
tree | 193d912ab0b810b77d235b58f390501341f3c803 /test | |
parent | 1a28402ced086b7a0bd9a4dcac6ec2ab687aec52 (diff) | |
download | ruby-c8726d8ed923ed867a89f55d39f45ff43aa06ff6.tar.gz ruby-c8726d8ed923ed867a89f55d39f45ff43aa06ff6.tar.xz ruby-c8726d8ed923ed867a89f55d39f45ff43aa06ff6.zip |
* lib/tempfile.rb (Tempfile#initialize): option hash may not be
given. [ruby-core:26681]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_tempfile.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 9a90d605e..073a11e15 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -3,6 +3,11 @@ require 'tempfile' require_relative 'ruby/envutil' class TestTempfile < Test::Unit::TestCase + def initialize(*) + super + @tempfile = nil + end + def tempfile(*args, &block) t = Tempfile.new(*args, &block) @tempfile = (t unless block) @@ -45,13 +50,13 @@ class TestTempfile < Test::Unit::TestCase def test_basename t = tempfile("foo") - assert_match /^foo/, File.basename(t.path) + assert_match(/^foo/, File.basename(t.path)) end def test_basename_with_suffix t = tempfile(["foo", ".txt"]) - assert_match /^foo/, File.basename(t.path) - assert_match /\.txt$/, File.basename(t.path) + assert_match(/^foo/, File.basename(t.path)) + assert_match(/\.txt$/, File.basename(t.path)) end def test_unlink @@ -284,5 +289,14 @@ puts Tempfile.new('foo').path t.rewind assert_equal(Encoding::ASCII_8BIT,t.read.encoding) end + + def test_binmode + t = tempfile("TEST", mode: IO::BINARY) + if IO::BINARY.nonzero? + assert(t.binmode?) + else + assert_equal(0600, t.stat.mode & 0777) + end + end end |