mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
e4f8e61ddd
commit
f09f597422
11 changed files with 882 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue