diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-24 20:26:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-24 20:26:34 +0000 |
commit | 8d3bb806b0fd301d5180a211dfe5880fd2ee2506 (patch) | |
tree | 812bf13d1f79b30df672fad073f6a9226f8b4ede /test | |
parent | b2d009fc7bead0a8c0ee45821acd46defa8a912b (diff) | |
download | ruby-8d3bb806b0fd301d5180a211dfe5880fd2ee2506.tar.gz |
* test/ruby/envutil.rb (EnvUtil#.suppress_warning): added.
* test/ruby/test_float.rb (TestFloat#test_Float): suppress
warnings under --verbose.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/envutil.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_float.rb | 7 |
2 files changed, 15 insertions, 4 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 978bf770bf..0d5632d4d9 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -100,6 +100,14 @@ module EnvUtil end module_function :verbose_warning + def suppress_warning + verbose, $VERBOSE = $VERBOSE, nil + yield + ensure + $VERBOSE = verbose + end + module_function :suppress_warning + def under_gc_stress stress, GC.stress = GC.stress, true yield @@ -114,7 +122,7 @@ module Test module Assertions public def assert_normal_exit(testsrc, message = '', opt = {}) - stdout, stderr, status = EnvUtil.invoke_ruby(%W'-W0', testsrc, true, true, opt) + _, _, status = EnvUtil.invoke_ruby(%W'-W0', testsrc, true, true, opt) pid = status.pid faildesc = proc do signo = status.termsig @@ -161,7 +169,7 @@ module Test end def assert_ruby_status(args, test_stdin="", message=nil, opt={}) - stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, false, false, opt) + _, _, status = EnvUtil.invoke_ruby(args, test_stdin, false, false, opt) m = message ? "#{message} (#{status.inspect})" : "ruby exit status is not success: #{status.inspect}" assert(status.success?, m) end diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 03d9c94766..5f3e98a6fd 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -1,6 +1,9 @@ require 'test/unit' +require_relative 'envutil' class TestFloat < Test::Unit::TestCase + include EnvUtil + def test_float assert_equal(2, 2.6.floor) assert_equal(-3, (-2.6).floor) @@ -426,10 +429,10 @@ class TestFloat < Test::Unit::TestCase def test_Float assert_in_delta(0.125, Float("0.1_2_5"), 0.00001) assert_in_delta(0.125, "0.1_2_5__".to_f, 0.00001) - assert_equal(1, Float(([1] * 10000).join).infinite?) + assert_equal(1, suppress_warning {Float(([1] * 10000).join)}.infinite?) assert(!Float(([1] * 10000).join("_")).infinite?) # is it really OK? assert_raise(ArgumentError) { Float("1.0\x001") } - assert_equal(1, Float("1e10_00").infinite?) + assert_equal(1, suppress_warning {Float("1e10_00")}.infinite?) assert_raise(TypeError) { Float(nil) } o = Object.new def o.to_f; inf = Float::INFINITY; inf/inf; end |