ruby-changes:30133
From: nobu <ko1@a...>
Date: Fri, 26 Jul 2013 13:20:05 +0900 (JST)
Subject: [ruby-changes:30133] nobu:r42185 (trunk): test_require.rb: use assert_separately
nobu 2013-07-26 13:19:51 +0900 (Fri, 26 Jul 2013) New Revision: 42185 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42185 Log: test_require.rb: use assert_separately * test/ruby/test_require.rb: use assert_separately preferably to assert_in_out_err for clear messages. Modified files: trunk/test/ruby/test_require.rb Index: test/ruby/test_require.rb =================================================================== --- test/ruby/test_require.rb (revision 42184) +++ test/ruby/test_require.rb (revision 42185) @@ -18,24 +18,20 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L18 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L167 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L196 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L228 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L243 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L290 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/