summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 04:19:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 04:19:51 +0000
commit4af852faa2ede75869debebeb04869c4cfbfb5a6 (patch)
tree5f0eb33e306181ca04ff2f4ce91b2f38b6e149fd
parent5cbfd7509c1d7a67a2ec972c37d5d641eb021f8f (diff)
test_require.rb: use assert_separately
* test/ruby/test_require.rb: use assert_separately preferably to assert_in_out_err for clear messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_require.rb99
1 files changed, 30 insertions, 69 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 41cbff5c02..e3da03606b 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -18,24 +18,20 @@ class TestRequire < Test::Unit::TestCase
t.puts "dummy"
t.close
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
$:.replace([IO::NULL])
- begin
+ assert_raise(LoadError) do
require \"#{ t.path }\"
- rescue LoadError
- p :ok
end
INPUT
}
end
def test_require_too_long_filename
- assert_in_out_err(["RUBYOPT"=>nil], <<-INPUT, %w(:ok), [])
+ assert_separately(["RUBYOPT"=>nil], <<-INPUT)
$:.replace([IO::NULL])
- begin
+ assert_raise(LoadError) do
require '#{ "foo/" * 10000 }foo'
- rescue LoadError
- p :ok
end
INPUT
@@ -171,33 +167,24 @@ class TestRequire < Test::Unit::TestCase
return
end
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
BasicSocket = 1
- begin
+ assert_raise(TypeError) do
require 'socket'
- p :ng
- rescue TypeError
- p :ok
end
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
class BasicSocket; end
- begin
+ assert_raise(TypeError) do
require 'socket'
- p :ng
- rescue TypeError
- p :ok
end
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
class BasicSocket < IO; end
- begin
+ assert_nothing_raised do
require 'socket'
- p :ok
- rescue Exception
- p :ng
end
INPUT
end
@@ -209,36 +196,27 @@ class TestRequire < Test::Unit::TestCase
return
end
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
module Zlib; end
Zlib::Error = 1
- begin
+ assert_raise(TypeError) do
require 'zlib'
- p :ng
- rescue TypeError
- p :ok
end
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
module Zlib; end
class Zlib::Error; end
- begin
+ assert_raise(NameError) do
require 'zlib'
- p :ng
- rescue NameError
- p :ok
end
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
module Zlib; end
class Zlib::Error < StandardError; end
- begin
+ assert_nothing_raised do
require 'zlib'
- p :ok
- rescue Exception
- p :ng
end
INPUT
end
@@ -250,13 +228,10 @@ class TestRequire < Test::Unit::TestCase
return
end
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
Zlib = 1
- begin
+ assert_raise(TypeError) do
require 'zlib'
- p :ng
- rescue TypeError
- p :ok
end
INPUT
end
@@ -268,15 +243,12 @@ class TestRequire < Test::Unit::TestCase
return
end
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
class BasicSocket < IO; end
class Socket < BasicSocket; end
Socket::Constants = 1
- begin
+ assert_raise(TypeError) do
require 'socket'
- p :ng
- rescue TypeError
- p :ok
end
INPUT
end
@@ -318,47 +290,36 @@ class TestRequire < Test::Unit::TestCase
abs_dir, file = File.split(t.path)
abs_dir = File.expand_path(abs_dir).untaint
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
abs_dir = "#{ abs_dir }"
$: << abs_dir
- require "#{ file }"
- p :ok
+ assert_nothing_raised {require "#{ file }"}
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
abs_dir = "#{ abs_dir }"
$: << abs_dir.taint
- require "#{ file }"
- p :ok
+ assert_nothing_raised {require "#{ file }"}
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
abs_dir = "#{ abs_dir }"
$: << abs_dir.taint
$SAFE = 1
- begin
- require "#{ file }"
- rescue SecurityError
- p :ok
- end
+ assert_raise(SecurityError) {require "#{ file }"}
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
abs_dir = "#{ abs_dir }"
$: << abs_dir.taint
$SAFE = 1
- begin
- require "#{ file }"
- rescue SecurityError
- p :ok
- end
+ assert_raise(SecurityError) {require "#{ file }"}
INPUT
- assert_in_out_err([], <<-INPUT, %w(:ok), [])
+ assert_separately([], <<-INPUT)
abs_dir = "#{ abs_dir }"
$: << abs_dir << 'elsewhere'.taint
- require "#{ file }"
- p :ok
+ assert_nothing_raised {require "#{ file }"}
INPUT
}
end