summaryrefslogtreecommitdiff
path: root/test/ruby/test_integer.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-20 14:07:35 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-20 15:35:31 +0900
commit7563604fb868d87057733f52d780d841fc1ab6bb (patch)
tree886c3624e49a970cd9469cf3e2a717c1e6735654 /test/ruby/test_integer.rb
parent4f1e0bfacd93c28bff549e2f3603c3b4942429a3 (diff)
[Bug #18998] Honor `#to_str` next to `#to_int` in `Kernel#Integer`
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6598
Diffstat (limited to 'test/ruby/test_integer.rb')
-rw-r--r--test/ruby/test_integer.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index c3e11498be..886888e7b0 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -247,6 +247,13 @@ class TestInteger < Test::Unit::TestCase
end;
end
+ def test_Integer_when_to_str
+ def (obj = Object.new).to_str
+ "0x10"
+ end
+ assert_equal(16, Integer(obj))
+ end
+
def test_int_p
assert_not_predicate(1.0, :integer?)
assert_predicate(1, :integer?)