From f09f597422b4130727638e41b1332edac1514642 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 14 May 2008 12:52:17 +0000 Subject: * test/ruby/test_object.rb: new tests to achieve over 90% test coverage of object.c, eval.c and eval_method.c. * test/ruby/test_module.rb: ditto. * test/ruby/test_trace.rb: ditto. * test/ruby/test_integer.rb: ditto. * test/ruby/test_float.rb: ditto. * test/ruby/test_method.rb: ditto. * test/ruby/test_variable.rb: ditto. * test/ruby/test_eval.rb: ditto. * test/ruby/test_exception.rb: ditto. * test/ruby/test_class.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_float.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/ruby/test_float.rb') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 9c4550e38d..ff4cf3fba1 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -405,4 +405,26 @@ class TestFloat < Test::Unit::TestCase } end + 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(Float(([1] * 10000).join).infinite?) + assert(!Float(([1] * 10000).join("_")).infinite?) # is it really OK? + assert_raise(ArgumentError) { Float("1.0\x001") } + assert(Float("1e10_00").infinite?) + assert_raise(TypeError) { Float(nil) } + o = Object.new + def o.to_f; inf = 1.0/0.0; inf/inf; end + assert_raise(ArgumentError) { Float(o) } + end + + def test_num2dbl + assert_raise(TypeError) do + 1.0.step(2.0, "0.5") {} + end + assert_raise(TypeError) do + 1.0.step(2.0, nil) {} + end + end + end -- cgit v1.2.3