summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_bignum.rb10
-rw-r--r--test/ruby/test_complex.rb24
-rw-r--r--test/ruby/test_fixnum.rb12
-rw-r--r--test/ruby/test_rational.rb9
4 files changed, 55 insertions, 0 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 582a326eb63..15811d5d432 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -778,5 +778,15 @@ class TestBignum < Test::Unit::TestCase
assert_raise(TypeError) { T1024P.digits("10") }
assert_raise(TypeError) { T1024P.digits("a") }
end
+
+ def test_finite_p
+ assert_predicate(T1024P, :finite?)
+ assert_predicate(-T1024P, :finite?)
+ end
+
+ def test_infinite_p
+ assert_nil(T1024P.infinite?)
+ assert_nil((-T1024P).infinite?)
+ end
end
end
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 6d189f46dd3..93d24a194a7 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -826,6 +826,30 @@ class Complex_Test < Test::Unit::TestCase
end
end
+ def test_finite_p
+ assert_predicate(1+1i, :finite?)
+ assert_predicate(1-1i, :finite?)
+ assert_predicate(-1+1i, :finite?)
+ assert_predicate(-1-1i, :finite?)
+ assert_not_predicate(Float::INFINITY + 1i, :finite?)
+ assert_not_predicate(Complex(1, Float::INFINITY), :finite?)
+ end
+
+ def test_infinite_p
+ assert_nil((1+1i).infinite?)
+ assert_nil((1-1i).infinite?)
+ assert_nil((-1+1i).infinite?)
+ assert_nil((-1-1i).infinite?)
+ assert_equal(1, (Float::INFINITY + 1i).infinite?)
+ assert_equal(1, (Float::INFINITY - 1i).infinite?)
+ assert_equal(1, (-Float::INFINITY + 1i).infinite?)
+ assert_equal(1, (-Float::INFINITY - 1i).infinite?)
+ assert_equal(1, Complex(1, Float::INFINITY).infinite?)
+ assert_equal(1, Complex(-1, Float::INFINITY).infinite?)
+ assert_equal(1, Complex(1, -Float::INFINITY).infinite?)
+ assert_equal(1, Complex(-1, -Float::INFINITY).infinite?)
+ end
+
def test_supp
assert_equal(true, 1.real?)
assert_equal(true, 1.1.real?)
diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb
index 3a1c2fa8bc5..bd18067dda8 100644
--- a/test/ruby/test_fixnum.rb
+++ b/test/ruby/test_fixnum.rb
@@ -337,4 +337,16 @@ class TestFixnum < Test::Unit::TestCase
assert_not_predicate(0, :negative?)
assert_not_predicate(1, :negative?)
end
+
+ def test_finite_p
+ assert_predicate(1, :finite?)
+ assert_predicate(0, :finite?)
+ assert_predicate(-1, :finite?)
+ end
+
+ def test_infinite_p
+ assert_nil(1.infinite?)
+ assert_nil(0.infinite?)
+ assert_nil(-1.infinite?)
+ end
end
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 07d0ae5688e..1fa9ebe8651 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -939,4 +939,13 @@ class Rational_Test < Test::Unit::TestCase
def test_known_bug
end
+ def test_finite_p
+ assert_predicate(1/2r, :finite?)
+ assert_predicate(-1/2r, :finite?)
+ end
+
+ def test_infinite_p
+ assert_nil((1/2r).infinite?)
+ assert_nil((-1/2r).infinite?)
+ end
end