aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_numeric.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_numeric.rb')
-rw-r--r--test/ruby/test_numeric.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 5a7a4e3765..f539ccf731 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -146,6 +146,30 @@ class TestNumeric < Test::Unit::TestCase
assert_predicate(a, :zero?)
end
+ def test_positive_p
+ a = Class.new(Numeric) do
+ def >(x); true; end
+ end.new
+ assert_predicate(a, :positive?)
+
+ a = Class.new(Numeric) do
+ def >(x); false; end
+ end.new
+ assert_not_predicate(a, :positive?)
+ end
+
+ def test_negative_p
+ a = Class.new(Numeric) do
+ def <(x); true; end
+ end.new
+ assert_predicate(a, :negative?)
+
+ a = Class.new(Numeric) do
+ def <(x); false; end
+ end.new
+ assert_not_predicate(a, :negative?)
+ end
+
def test_to_int
a = Class.new(Numeric) do
def to_i; :ok; end