diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-15 15:26:04 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-15 15:26:04 +0000 |
commit | eafe85f603e0db7caee9d719a55bfe3173f9061b (patch) | |
tree | 288c8beeee33cfac193f338773675cc3afc17b23 /test/ruby/test_object.rb | |
parent | e74af2cf41d3fc3accbcf153d0a73454f29a1c7f (diff) | |
download | ruby-eafe85f603e0db7caee9d719a55bfe3173f9061b.tar.gz |
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err): new
method.
* test/ruby/test_argf.rb: use assert_in_out_err instead of
EnvUtil.rubyexec.
* test/ruby/test_module.rb: ditto.
* test/ruby/test_require.rb: ditto.
* test/ruby/test_objectspace.rb: ditto.
* test/ruby/test_object.rb: ditto.
* test/ruby/test_string.rb: ditto.
* test/ruby/test_method.rb: ditto.
* test/ruby/test_variable.rb: ditto.
* test/ruby/test_io.rb: ditto.
* test/ruby/test_rubyoptions.rb: ditto.
* test/ruby/test_exception.rb: ditto.
* test/ruby/test_class.rb: ditto.
* test/ruby/test_thread.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_object.rb')
-rw-r--r-- | test/ruby/test_object.rb | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 7878bf5597..14ce98f8bc 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -11,10 +11,6 @@ class TestObject < Test::Unit::TestCase $VERBOSE = @verbose end - def ruby(*r, &b) - EnvUtil.rubyexec(*r, &b) - end - def test_dup assert_raise(TypeError) { 1.dup } assert_raise(TypeError) { true.dup } @@ -220,34 +216,25 @@ class TestObject < Test::Unit::TestCase end def test_redefine_method_under_verbose - ruby do |w, r, e| - w.puts "$VERBOSE = true" - w.puts "o = Object.new" - w.puts "def o.foo; 1; end" - w.puts "def o.foo; 2; end" - w.puts "p o.foo" - w.close - assert_equal("2", r.read.chomp) - assert_match(/warning: method redefined; discarding old foo$/, e.read.chomp) - end + assert_in_out_err([], <<-INPUT, %w(2), /warning: method redefined; discarding old foo$/) + $VERBOSE = true + o = Object.new + def o.foo; 1; end + def o.foo; 2; end + p o.foo + INPUT end def test_redefine_method_which_may_case_serious_problem - ruby do |w, r, e| - w.puts "$VERBOSE = false" - w.puts "def (Object.new).object_id; end" - w.close - assert_equal("", r.read.chomp) - assert_match(/warning: redefining `object_id' may cause serious problem$/, e.read.chomp) - end + assert_in_out_err([], <<-INPUT, [], /warning: redefining `object_id' may cause serious problem$/) + $VERBOSE = false + def (Object.new).object_id; end + INPUT - ruby do |w, r, e| - w.puts "$VERBOSE = false" - w.puts "def (Object.new).__send__; end" - w.close - assert_equal("", r.read.chomp) - assert_match(/warning: redefining `__send__' may cause serious problem$/, e.read.chomp) - end + assert_in_out_err([], <<-INPUT, [], /warning: redefining `__send__' may cause serious problem$/) + $VERBOSE = false + def (Object.new).__send__; end + INPUT end def test_remove_method @@ -272,17 +259,14 @@ class TestObject < Test::Unit::TestCase end %w(object_id __send__ initialize).each do |m| - ruby do |w, r, e| - w.puts "$VERBOSE = false" - w.puts "begin" - w.puts " Class.new.instance_eval { remove_method(:#{m}) }" - w.puts "rescue NameError" - w.puts " p :ok" - w.puts "end" - w.close - assert_equal(":ok", r.read.chomp) - assert_match(/warning: removing `#{m}' may cause serious problem$/, e.read.chomp) - end + assert_in_out_err([], <<-INPUT, %w(:ok), /warning: removing `#{m}' may cause serious problem$/) + $VERBOSE = false + begin + Class.new.instance_eval { remove_method(:#{m}) } + rescue NameError + p :ok + end + INPUT end end |