Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs for invalid base argument in Kernel.Integer #1111

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/kernel/Integer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@
Integer("777", obj).should == 0777
end

# https://bugs.ruby-lang.org/issues/19349
ruby_version_is ''...'3.3' do
it "ignores the base if it is not an integer and does not respond to #to_i" do
Integer("777", "8").should == 777
end
end

ruby_version_is '3.3' do
it "raises a TypeError if it is not an integer and does not respond to #to_i" do
-> {
Integer("777", "8")
}.should raise_error(TypeError, "no implicit conversion of String into Integer")
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems Ruby calls #to_int, not #to_i


describe "when passed exception: false" do
describe "and valid argument" do
it "returns an Integer number" do
Expand Down
Loading