summaryrefslogtreecommitdiff
path: root/test/-ext-/integer
diff options
context:
space:
mode:
Diffstat (limited to 'test/-ext-/integer')
-rw-r--r--test/-ext-/integer/test_integer.rb10
-rw-r--r--test/-ext-/integer/test_my_integer.rb34
2 files changed, 16 insertions, 28 deletions
diff --git a/test/-ext-/integer/test_integer.rb b/test/-ext-/integer/test_integer.rb
index 8d7785047b..26263211e6 100644
--- a/test/-ext-/integer/test_integer.rb
+++ b/test/-ext-/integer/test_integer.rb
@@ -16,11 +16,11 @@ class Test_Integer < Test::Unit::TestCase
def test_positive_pow
assert_separately(%w[-r-test-/integer], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 3)
begin;
- assert_equal(1, 1.positive_pow(1))
- assert_equal(0, 0.positive_pow(1))
- assert_equal(3, 3.positive_pow(1))
- assert_equal(-3, -3.positive_pow(1))
- assert_equal(9, -3.positive_pow(2))
+ assert_equal(1, Bug::Integer.positive_pow(1, 1))
+ assert_equal(0, Bug::Integer.positive_pow(0, 1))
+ assert_equal(3, Bug::Integer.positive_pow(3, 1))
+ assert_equal(-3, Bug::Integer.positive_pow(-3, 1))
+ assert_equal(9, Bug::Integer.positive_pow(-3, 2))
end;
end
end
diff --git a/test/-ext-/integer/test_my_integer.rb b/test/-ext-/integer/test_my_integer.rb
index 1b6f8489f8..0dfa234921 100644
--- a/test/-ext-/integer/test_my_integer.rb
+++ b/test/-ext-/integer/test_my_integer.rb
@@ -8,19 +8,13 @@ class Test_MyInteger < Test::Unit::TestCase
Bug::Integer::MyInteger.new.to_f
end
- begin
- Bug::Integer::MyInteger.class_eval do
- def to_f
- end
+ int = Class.new(Bug::Integer::MyInteger) do
+ def to_f
end
+ end
- assert_nothing_raised do
- Bug::Integer::MyInteger.new.to_f
- end
- ensure
- Bug::Integer::MyInteger.class_eval do
- remove_method :to_f
- end
+ assert_nothing_raised do
+ int.new.to_f
end
end
@@ -29,20 +23,14 @@ class Test_MyInteger < Test::Unit::TestCase
Bug::Integer::MyInteger.new <=> 0
end
- begin
- Bug::Integer::MyInteger.class_eval do
- def <=>(other)
- 0
- end
+ int = Class.new(Bug::Integer::MyInteger) do
+ def <=>(other)
+ 0
end
+ end
- assert_nothing_raised do
- Bug::Integer::MyInteger.new <=> 0
- end
- ensure
- Bug::Integer::MyInteger.class_eval do
- remove_method :<=>
- end
+ assert_nothing_raised do
+ int.new <=> 0
end
end
end