1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/-ext-
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
..
arith_seq
array
bignum
bug_reporter skip SEGV test if RUBY_ON_BUG is specified 2020-02-13 04:20:22 +09:00
class
debug vm_backtrace.c: let rb_profile_frames show cfunc frames 2020-07-28 13:18:08 +09:00
exception
file
float
funcall
gvl
hash
integer
iseq_load
iter
load
marshal
method
num2int
path_to_class
popen_deadlock
postponed_job
proc
rational rb_rational_raw: convert num and den by to_int 2020-01-17 10:57:51 +09:00
st
string Make String methods return String instances when called on a subclass instance 2020-11-20 16:30:23 -08:00
struct
symbol Make Thread#thread_variable? similar to #thread_variable_get 2020-05-25 21:38:35 -07:00
thread_fd_close
time
tracepoint keep proc on the stack so it does not move 2020-10-16 11:28:52 -07:00
typeddata
vm
wait_for_single_fd
win32
test_bug-3571.rb
test_bug-5832.rb
test_bug-14834.rb
test_enumerator_kw.rb
test_notimplement.rb Moved not-implemented method tests [Bug #16662] 2020-02-28 21:15:37 +09:00
test_printf.rb
test_random.rb Added get_real interface 2020-09-07 20:08:01 +09:00
test_recursion.rb
test_scan_args.rb