summaryrefslogtreecommitdiff
path: root/test/ruby/test_integer.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-09-07 10:57:52 -0700
committerGitHub <noreply@github.com>2023-09-07 10:57:52 -0700
commit5b5ae3d9e064e17e2a7d8d21d739fcc62ae1075c (patch)
treefde0e41fdd741cac9434969fa2d2a2df0d90e7e5 /test/ruby/test_integer.rb
parent4efcaf956e27df365a1cf9e0cbb8d9a68eeb6995 (diff)
Rewrite Integer#times in Ruby (#8388)
Notes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'test/ruby/test_integer.rb')
-rw-r--r--test/ruby/test_integer.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 3e8d68702c..31cb8d6cf5 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -321,23 +321,34 @@ class TestInteger < Test::Unit::TestCase
begin;
called = false
Integer.class_eval do
- alias old_plus +
- undef +
- define_method(:+){|x| called = true; 1}
+ alias old_succ succ
+ undef succ
+ define_method(:succ){|x| called = true; x+1}
alias old_lt <
undef <
define_method(:<){|x| called = true}
end
+
+ fix = 1
+ fix.times{break 0}
+ fix_called = called
+
+ called = false
+
big = 2**65
big.times{break 0}
+ big_called = called
+
Integer.class_eval do
- undef +
- alias + old_plus
+ undef succ
+ alias succ old_succ
undef <
alias < old_lt
end
+
+ # Asssert that Fixnum and Bignum behave consistently
bug18377 = "[ruby-core:106361]"
- assert_equal(false, called, bug18377)
+ assert_equal(fix_called, big_called, bug18377)
end;
end