diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-20 00:17:25 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-20 00:17:25 +0000 |
commit | c267d24ef0b4955ee5d0538707ed47d1b6278699 (patch) | |
tree | 7cc4faa9287f8400cfec82f20e1900def66a705b /test | |
parent | 895b44dcf6d94e58f3daaf78d58453e2735ee827 (diff) | |
download | ruby-c267d24ef0b4955ee5d0538707ed47d1b6278699.tar.gz |
* vm.c (rb_vm_cref_replace_with_duplicated_cref): added.
CREFs should not be shared by methods between `using'.
[Bug #11247]
* vm_insnhelper.c (vm_cref_replace_with_duplicated_cref): ditto.
* vm.c (vm_cref_dup): should copy refinements correctly.
* eval.c: use rb_vm_cref_replace_with_duplicated_cref().
* eval_intern.h: add a decl. of
rb_vm_cref_replace_with_duplicated_cref().
* vm_eval.c (eval_string_with_cref): do not need to pass
scope's CREF because VM can find out CREF from stack frames.
* test/ruby/test_refinement.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_refinement.rb | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 43f58b1038..80407c01a2 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1523,6 +1523,77 @@ class TestRefinement < Test::Unit::TestCase end; end + module MixedUsing1 + class C + def foo + :orig_foo + end + end + + module R1 + refine C do + def foo + [:R1, super] + end + end + end + + module_function + + def foo + [:foo, C.new.foo] + end + + using R1 + + def bar + [:bar, C.new.foo] + end + end + + module MixedUsing2 + class C + def foo + :orig_foo + end + end + + module R1 + refine C do + def foo + [:R1_foo, super] + end + end + end + + module R2 + refine C do + def bar + [:R2_bar, C.new.foo] + end + + using R1 + + def baz + [:R2_baz, C.new.foo] + end + end + end + + using R2 + module_function + def f1; C.new.bar; end + def f2; C.new.baz; end + end + + def test_mixed_using + assert_equal([:foo, :orig_foo], MixedUsing1.foo) + assert_equal([:bar, [:R1, :orig_foo]], MixedUsing1.bar) + + assert_equal([:R2_bar, :orig_foo], MixedUsing2.f1) + assert_equal([:R2_baz, [:R1_foo, :orig_foo]], MixedUsing2.f2) + end + private def eval_using(mod, s) |