Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions spec/std/string_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,13 @@ describe "String" do
it { "1101".to_i(base: 2).should eq(13) }
it { "12ab".to_i(16).should eq(4779) }
it { "0x123abc".to_i(prefix: true).should eq(1194684) }
it { "0X123abc".to_i(prefix: true).should eq(1194684) }
it { "0b1101".to_i(prefix: true).should eq(13) }
it { "0B1101".to_i(prefix: true).should eq(13) }
it { "0b001101".to_i(prefix: true).should eq(13) }
it { "0123".to_i(prefix: true).should eq(123) }
it { "0o123".to_i(prefix: true).should eq(83) }
it { "0O123".to_i(prefix: true).should eq(83) }
it { "0123".to_i(leading_zero_is_octal: true).should eq(83) }
it { "123".to_i(leading_zero_is_octal: true).should eq(123) }
it { "0o755".to_i(prefix: true, leading_zero_is_octal: true).should eq(493) }
Expand Down
6 changes: 3 additions & 3 deletions src/string.cr
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,13 @@ class String
last_is_underscore = false
if prefix
case ptr.value.unsafe_chr
when 'b'
when 'b', 'B'
base = 2
ptr += 1
when 'x'
when 'x', 'X'
base = 16
ptr += 1
when 'o'
when 'o', 'O'
base = 8
ptr += 1
else
Expand Down
Loading