1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/core/string/shared
Jeremy Evans 58325daae3 Make String methods return String instances when called on a subclass instance
This modifies the following String methods to return String instances
instead of subclass instances:

* String#*
* String#capitalize
* String#center
* String#chomp
* String#chop
* String#delete
* String#delete_prefix
* String#delete_suffix
* String#downcase
* String#dump
* String#each/#each_line
* String#gsub
* String#ljust
* String#lstrip
* String#partition
* String#reverse
* String#rjust
* String#rpartition
* String#rstrip
* String#scrub
* String#slice!
* String#slice/#[]
* String#split
* String#squeeze
* String#strip
* String#sub
* String#succ/#next
* String#swapcase
* String#tr
* String#tr_s
* String#upcase

This also fixes a bug in String#swapcase where it would return the
receiver instead of a copy of the receiver if the receiver was the
empty string.

Some string methods were left to return subclass instances:

* String#+@
* String#-@

Both of these methods will return the receiver (subclass instance)
in some cases, so it is best to keep the returned class consistent.

Fixes [#10845]
2020-11-20 16:30:23 -08:00
..
chars.rb Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
codepoints.rb Update to ruby/spec@875a09e 2019-07-27 12:40:09 +02:00
concat.rb Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
each_char_without_block.rb
each_codepoint_without_block.rb
each_line.rb Make String methods return String instances when called on a subclass instance 2020-11-20 16:30:23 -08:00
each_line_without_block.rb
encode.rb Update to ruby/spec@519df35 2019-09-29 16:03:58 +02:00
eql.rb
equal_value.rb
grapheme_clusters.rb
length.rb Update to ruby/spec@f8a2d54 2020-01-28 20:47:48 +01:00
replace.rb Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
slice.rb Make String methods return String instances when called on a subclass instance 2020-11-20 16:30:23 -08:00
succ.rb Make String methods return String instances when called on a subclass instance 2020-11-20 16:30:23 -08:00
to_a.rb
to_s.rb Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
to_sym.rb Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00