Skip to content

Commit

Permalink
String: add specs for at, and fixed a small error
Browse files Browse the repository at this point in the history
Ary Borenszweig committed Jun 9, 2016

Verified

This commit was signed with the committer’s verified signature. The key has expired.
vbgl Vincent Laporte
1 parent 5d8c8bf commit 0f172ab
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions spec/std/string_spec.cr
Original file line number Diff line number Diff line change
@@ -1801,4 +1801,13 @@ describe "String" do
clone = string.clone
string.should be(clone)
end

it "#at" do
"foo".at(0).should eq('f')
"foo".at(4) { 'x' }.should eq('x')

expect_raises(IndexError) do
"foo".at(4)
end
end
end
2 changes: 1 addition & 1 deletion src/string.cr
Original file line number Diff line number Diff line change
@@ -730,7 +730,7 @@ class String
end

def at(index : Int)
at(index) { raise IndexError }
at(index) { raise IndexError.new }
end

def at(index : Int)

0 comments on commit 0f172ab

Please sign in to comment.