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
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
..
argf Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
array Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
basicobject Update to ruby/spec@875a09e 2019-07-27 12:40:09 +02:00
binding 2.8 -> 3.0 in specs 2020-09-15 21:56:00 +02:00
builtin_constants Update to ruby/spec@d419e74 2019-12-27 16:46:08 +01:00
class Improve error message when subclassing non-Class 2020-11-13 07:06:13 -08:00
comparable Update to ruby/spec@ec84479 2020-03-28 00:22:51 +01:00
complex Update to ruby/spec@e829fb0 2020-09-17 11:42:26 +02:00
data Update to ruby/spec@bfd843a 2020-09-30 13:43:19 +02:00
dir Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
encoding Update to ruby/spec@4f59d86 2020-10-24 15:53:53 +02:00
enumerable Update to ruby/spec@4f59d86 2020-10-24 15:53:53 +02:00
enumerator numeric.c, range.c: prohibit zero step 2020-10-23 15:26:51 +09:00
env Update to ruby/spec@4f59d86 2020-10-24 15:53:53 +02:00
exception Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
false Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
fiber Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
file Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
filetest Use rb_warn_deprecated for File.exists? and Dir.exists? 2020-04-06 21:43:32 +09:00
float Update to ruby/spec@335eb9b 2020-08-28 20:26:02 +02:00
gc Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
hash Update to ruby/spec@4f59d86 2020-10-24 15:53:53 +02:00
integer Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
io Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
kernel Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
main Update to ruby/spec@875a09e 2019-07-27 12:40:09 +02:00
marshal Update to ruby/spec@bfd843a 2020-09-30 13:43:19 +02:00
matchdata Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
math Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
method Update to ruby/spec@4f59d86 2020-10-24 15:53:53 +02:00
module Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
mutex 2.8 -> 3.0 in specs 2020-09-15 21:56:00 +02:00
nil Update to ruby/spec@e829fb0 2020-09-17 11:42:26 +02:00
numeric numeric.c, range.c: prohibit zero step 2020-10-23 15:26:51 +09:00
objectspace Fix typos [ci skip] 2020-10-19 13:20:34 +09:00
proc 2.8 -> 3.0 in specs 2020-09-15 21:56:00 +02:00
process Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
queue
random Drop support for ruby 2.4 from ruby/spec 2020-04-01 15:36:20 +09:00
range Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
rational Update to ruby/spec@875a09e 2019-07-27 12:40:09 +02:00
regexp 2.8 -> 3.0 in specs 2020-09-15 21:56:00 +02:00
signal Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
sizedqueue Update to ruby/spec@875a09e 2019-07-27 12:40:09 +02:00
string Make String methods return String instances when called on a subclass instance 2020-11-20 16:30:23 -08:00
struct Drop support for ruby 2.4 from ruby/spec 2020-04-01 15:36:20 +09:00
symbol Update to ruby/spec@e829fb0 2020-09-17 11:42:26 +02:00
systemexit Update to ruby/spec@032ee74 2020-05-03 12:28:29 +02:00
thread Update to ruby/spec@b0b7f53 2020-11-13 13:17:24 +01:00
threadgroup Update to ruby/spec@875a09e 2019-07-27 12:40:09 +02:00
time 2.8 -> 3.0 in specs 2020-09-15 21:56:00 +02:00
tracepoint 2.8 -> 3.0 in specs 2020-09-15 21:56:00 +02:00
true Update to ruby/spec@e829fb0 2020-09-17 11:42:26 +02:00
unboundmethod Update to ruby/spec@4f59d86 2020-10-24 15:53:53 +02:00
warning Fix Rubyspec (ruby-2.7) failures 2020-11-01 17:37:03 +09:00