Skip to content

Commit

Permalink
[1.9] String#chr fixes for the following tests:
Browse files Browse the repository at this point in the history
String#chr returns a copy of self
String#chr returns a String
String#chr returns an empty String if self is an empty String
String#chr returns a 1-character String
String#chr returns the character at the start of the String
String#chr returns a String in the same encoding as self
  • Loading branch information
carsonmcdonald committed Oct 17, 2011
1 parent 02a346d commit fdb3aa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 12 additions & 0 deletions kernel/common/string19.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,4 +631,16 @@ def <<(other)
end
alias_method :concat, :<<

# Returns a one-character string at the beginning of the string.
#
# a = "abcde"
# a.chr #=> "a"
def chr
if empty?
self
else
self[0]
end
end

end
6 changes: 0 additions & 6 deletions spec/tags/19/ruby/core/string/chr_tags.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
fails:String#chr returns a copy of self
fails:String#chr returns a String
fails:String#chr returns an empty String if self is an empty String
fails:String#chr returns a 1-character String
fails:String#chr returns the character at the start of the String
fails:String#chr returns a String in the same encoding as self
fails:String#chr understands multi-byte characters
fails:String#chr understands Strings that contain a mixture of character widths

0 comments on commit fdb3aa0

Please sign in to comment.