diff options
Diffstat (limited to 'test/ruby/test_float.rb')
-rw-r--r-- | test/ruby/test_float.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index eab4d12a29..f1e01fc249 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -356,6 +356,30 @@ class TestFloat < Test::Unit::TestCase assert_not_predicate(1.0, :zero?) end + def test_positive_p + assert_predicate(+1.0, :positive?) + assert_not_predicate(+0.0, :positive?) + assert_not_predicate(-0.0, :positive?) + assert_not_predicate(-1.0, :positive?) + assert_predicate(+(0.0.next_float), :positive?) + assert_not_predicate(-(0.0.next_float), :positive?) + assert_predicate(Float::INFINITY, :positive?) + assert_not_predicate(-Float::INFINITY, :positive?) + assert_not_predicate(Float::NAN, :positive?) + end + + def test_negative_p + assert_predicate(-1.0, :negative?) + assert_not_predicate(-0.0, :negative?) + assert_not_predicate(+0.0, :negative?) + assert_not_predicate(+1.0, :negative?) + assert_predicate(-(0.0.next_float), :negative?) + assert_not_predicate(+(0.0.next_float), :negative?) + assert_predicate(-Float::INFINITY, :negative?) + assert_not_predicate(Float::INFINITY, :negative?) + assert_not_predicate(Float::NAN, :negative?) + end + def test_infinite_p inf = Float::INFINITY assert_equal(1, inf.infinite?) |