1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/ruby
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
..
enc
allpairs.rb
beginmainend.rb
bug-11928.rb
bug-13526.rb
lbtest.rb
marshaltestlib.rb
sentence.rb
test_alias.rb
test_argf.rb
test_arithmetic_sequence.rb
test_arity.rb
test_array.rb
test_assignment.rb
test_ast.rb
test_autoload.rb fix for multi-run test. 2020-05-15 14:54:03 +09:00
test_backtrace.rb
test_basicinstructions.rb
test_beginendblock.rb
test_bignum.rb
test_call.rb
test_case.rb
test_class.rb
test_clone.rb
test_comparable.rb
test_complex.rb
test_complex2.rb
test_complexrational.rb
test_condition.rb
test_const.rb
test_continuation.rb
test_default_gems.rb
test_defined.rb Fixed defined? against protected method call 2020-06-02 19:01:56 +09:00
test_dir.rb
test_dir_m17n.rb
test_econv.rb
test_encoding.rb
test_enum.rb Ensure origins for all included, prepended, and refined modules 2020-06-03 09:50:37 -07:00
test_enumerator.rb
test_env.rb
test_eval.rb
test_exception.rb
test_fiber.rb Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
test_file.rb
test_file_exhaustive.rb
test_fixnum.rb
test_flip.rb
test_float.rb
test_fnmatch.rb
test_frozen_error.rb
test_gc.rb Run major GC three times to make sure the minor GC reason 2020-05-22 11:12:40 +09:00
test_gc_compact.rb
test_hash.rb
test_ifunless.rb
test_inlinecache.rb
test_integer.rb
test_integer_comb.rb
test_io.rb
test_io_m17n.rb
test_iseq.rb
test_iterator.rb
test_jit.rb
test_jit_debug.rb
test_key_error.rb
test_keyword.rb
test_lambda.rb
test_lazy_enumerator.rb
test_literal.rb
test_m17n.rb
test_m17n_comb.rb
test_marshal.rb
test_math.rb
test_metaclass.rb
test_method.rb
test_mixed_unicode_escapes.rb
test_module.rb Ensure origins for all included, prepended, and refined modules 2020-06-03 09:50:37 -07:00
test_name_error.rb Test for [Feature #16832] 2020-05-26 15:09:07 +09:00
test_nomethod_error.rb
test_not.rb
test_numeric.rb
test_object.rb
test_objectspace.rb
test_optimization.rb test/ruby/test_optimization.rb: Proc creation test should count :T_DATA 2020-05-21 13:27:26 +09:00
test_pack.rb
test_parse.rb
test_path.rb
test_pattern_matching.rb
test_pipe.rb
test_primitive.rb
test_proc.rb
test_process.rb test/ruby/test_process.rb: GID.from_name may raise Errno:ESRCH 2020-05-30 00:16:44 +09:00
test_rand.rb Removed useless implementation tests 2020-05-17 19:03:05 +09:00
test_range.rb
test_rational.rb
test_rational2.rb
test_readpartial.rb
test_refinement.rb
test_regexp.rb
test_require.rb
test_require_lib.rb
test_rubyoptions.rb
test_rubyvm.rb
test_rubyvm_mjit.rb
test_settracefunc.rb
test_signal.rb
test_sleep.rb
test_sprintf.rb
test_sprintf_comb.rb
test_stack.rb Removed trailing spaces [ci skip] 2020-05-14 19:57:39 +09:00
test_string.rb
test_stringchar.rb
test_struct.rb
test_super.rb
test_symbol.rb
test_syntax.rb Fixed argument forwarding in reserved word method [Bug #16854] 2020-05-15 14:59:11 +09:00
test_system.rb
test_thread.rb
test_thread_cv.rb
test_thread_queue.rb
test_threadgroup.rb
test_time.rb
test_time_tz.rb
test_trace.rb
test_transcode.rb
test_undef.rb
test_unicode_escape.rb
test_variable.rb
test_vm_dump.rb cause SEGV for the test. 2020-05-26 04:49:11 +09:00
test_weakmap.rb
test_whileuntil.rb
test_yield.rb
ut_eof.rb