1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test
Jeremy Evans 98286e9850 Ensure origins for all included, prepended, and refined modules
This fixes various issues when a module is included in or prepended
to a module or class, and then refined, or refined and then included
or prepended to a module or class.

Implement by renaming ensure_origin to rb_ensure_origin, making it
non-static, and calling it when refining a module.

Fix Module#initialize_copy to handle origins correctly.  Previously,
Module#initialize_copy did not handle origins correctly.  For example,
this code:

```ruby
module B; end
class A
  def b; 2 end
  prepend B
end
a = A.dup.new
class A
  def b; 1 end
end
p a.b
```

Printed 1 instead of 2.  This is because the super chain for
a.singleton_class was:

```
a.singleton_class
A.dup
B(iclass)
B(iclass origin)
A(origin) # not A.dup(origin)
```

The B iclasses would not be modified, so the includer entry would be
still be set to A and not A.dup.

This modifies things so that if the class/module has an origin,
all iclasses between the class/module and the origin are duplicated
and have the correct includer entry set, and the correct origin
is created.

This requires other changes to make sure all tests still pass:

* rb_undef_methods_from doesn't automatically handle classes with
  origins, so pass it the origin for Comparable when undefing
  methods in Complex. This fixed a failure in the Complex tests.

* When adding a method, the method cache was not cleared
  correctly if klass has an origin.  Clear the method cache for
  the klass before switching to the origin of klass.  This fixed
  failures in the autoload tests related to overridding require,
  without breaking the optimization tests.  Also clear the method
  cache for both the module and origin when removing a method.

* Module#include? is fixed to skip origin iclasses.

* Refinements are fixed to use the origin class of the module that
  has an origin.

* RCLASS_REFINED_BY_ANY is removed as it was only used in a single
  place and is no longer needed.

* Marshal#dump is fixed to skip iclass origins.

* rb_method_entry_make is fixed to handled overridden optimized
  methods for modules that have origins.

Fixes [Bug #16852]
2020-06-03 09:50:37 -07:00
..
-ext- Make Thread#thread_variable? similar to #thread_variable_get 2020-05-25 21:38:35 -07:00
base64
benchmark
bigdecimal
cgi need to restore $stdin. 2020-03-02 13:14:38 +09:00
coverage
csv Removed trailing spaces [ci skip] 2020-05-14 19:57:39 +09:00
date
dbm
did_you_mean Revert "Sync did_you_mean" 2020-05-12 16:27:25 +09:00
digest test/digest/test_digest.rb: Apply EnvUtil.apply_timeout_scale to timeout 2020-03-27 15:32:52 +09:00
drb Explicitly loading with envutil.rb 2020-05-28 14:41:08 +09:00
dtrace
erb
etc test/etc/test_etc.rb: skip some tests on Android 2020-02-12 17:28:29 +09:00
excludes
fiber Fixup d48c92aa04 2020-05-23 17:24:29 +09:00
fiddle [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33) 2020-05-23 14:34:07 +09:00
fileutils
gdbm
io Use %w instead of %i not to create unused IDs 2020-05-09 20:13:30 +09:00
irb Fix typos 2020-05-09 14:22:04 +09:00
json test/json/test_helper.rb: Do not add a relative path to $LOAD_PATH 2020-03-24 10:45:52 +09:00
lib test/lib/jit_support.rb: Let JIT tests skip on centos8 2020-05-12 17:48:31 +09:00
logger
matrix [ruby/matrix] Add Matrix#adjoint [#14] 2020-05-01 03:25:15 -04:00
mkmf
monitor
net [ruby/net-ftp] Added guard condition for the old ruby versions 2020-04-08 15:51:18 +09:00
nkf
objspace
open-uri
openssl [ruby/openssl] ssl: temporarily remove SSLContext#add_certificate_chain_file 2020-05-13 15:47:51 +09:00
optparse
ostruct Prefer dedicated assertion method 2020-02-25 17:47:17 +09:00
pathname
psych Fix remove warning & support multi-run test for test/psych/visitors/test_to_ruby.rb 2020-02-13 11:01:15 +09:00
racc
rdoc [ruby/rdoc] Check uninitialized instance variable in test 2020-05-24 23:47:24 +09:00
readline Restore class variable setting for tests 2020-05-14 12:27:33 +09:00
reline [ruby/reline] Add a test of autowrap for yamatanooroti 2020-05-17 19:26:53 +09:00
resolv
rinda Explicitly loading with envutil.rb 2020-05-28 14:41:08 +09:00
ripper Removed unnecessary RLIMIT_AS 2020-04-28 23:36:16 +09:00
ruby Ensure origins for all included, prepended, and refined modules 2020-06-03 09:50:37 -07:00
rubygems Run rb_syswait on exec failure 2020-05-10 00:59:55 -07:00
sdbm
socket Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
stringio [ruby/stringio] StringIO#initialize default to the source string encoding 2020-03-15 18:43:01 +09:00
strscan
syslog
uri Fakes IPSocket.getaddress in the whole method 2020-05-06 16:06:25 +09:00
webrick restore server[:DocumentRootOptions] setting. 2020-02-29 00:43:41 +09:00
win32ole
yaml
zlib
runner.rb
test_abbrev.rb
test_delegate.rb Fix SimpleDelegator respond_to? regression 2020-02-03 08:16:22 -08:00
test_extlibs.rb
test_find.rb
test_forwardable.rb
test_ipaddr.rb
test_mutex_m.rb
test_observer.rb
test_open3.rb
test_pp.rb Mask RubyVM-specific test 2020-03-05 16:49:27 -06:00
test_prettyprint.rb
test_prime.rb [ruby/prime] Fix Prime.include? 2020-03-06 20:54:33 +09:00
test_pstore.rb
test_pty.rb
test_rbconfig.rb Make RbConfig::CONFIG values mutable [Bug #16738] 2020-03-25 22:09:28 +09:00
test_securerandom.rb
test_set.rb
test_shellwords.rb
test_singleton.rb
test_syslog.rb Update some syslog tests to absurb the format change of FreeBSD syslog 2020-03-12 15:30:20 +09:00
test_tempfile.rb
test_time.rb
test_timeout.rb
test_tmpdir.rb Correctly remove temporary directory if path yielded is mutated 2020-05-29 07:06:46 -07:00
test_tracer.rb
test_tsort.rb
test_unicode_normalize.rb
test_weakref.rb
test_win32api.rb