aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_refinement.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-18 06:57:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-18 06:57:34 +0000
commitdd1baaabcd41a09356c7c536a0a616bd206478dd (patch)
tree2d251a412e25843433c352aeef1e3c818f90f933 /test/ruby/test_refinement.rb
parent6d2e8b0546e17bac4dc35bdf54ec19701d0d76d1 (diff)
downloadruby-dd1baaabcd41a09356c7c536a0a616bd206478dd.tar.gz
vm_method.c: method defined should not use refinements.
* vm_method.c (check_definition): Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined? should not use refinements. [ruby-core:67656] [Bug #10753] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_refinement.rb')
-rw-r--r--test/ruby/test_refinement.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 596c679610..df162545d5 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1235,6 +1235,81 @@ class TestRefinement < Test::Unit::TestCase
end;
end
+ def test_refined_method_defined
+ assert_separately([], <<-"end;")
+ bug10753 = '[ruby-core:67656] [Bug #10753]'
+
+ c = Class.new do
+ def refined_public; end
+ def refined_protected; end
+ def refined_private; end
+
+ public :refined_public
+ protected :refined_protected
+ private :refined_private
+ end
+
+ m = Module.new do
+ refine(c) do
+ def refined_public; end
+ def refined_protected; end
+ def refined_private; end
+
+ public :refined_public
+ protected :refined_protected
+ private :refined_private
+ end
+ end
+
+ using m
+
+ assert_equal(true, c.public_method_defined?(:refined_public), bug10753)
+ assert_equal(false, c.public_method_defined?(:refined_protected), bug10753)
+ assert_equal(false, c.public_method_defined?(:refined_private), bug10753)
+
+ assert_equal(false, c.protected_method_defined?(:refined_public), bug10753)
+ assert_equal(true, c.protected_method_defined?(:refined_protected), bug10753)
+ assert_equal(false, c.protected_method_defined?(:refined_private), bug10753)
+
+ assert_equal(false, c.private_method_defined?(:refined_public), bug10753)
+ assert_equal(false, c.private_method_defined?(:refined_protected), bug10753)
+ assert_equal(true, c.private_method_defined?(:refined_private), bug10753)
+ end;
+ end
+
+ def test_undefined_refined_method_defined
+ assert_separately([], <<-"end;")
+ bug10753 = '[ruby-core:67656] [Bug #10753]'
+
+ c = Class.new
+
+ m = Module.new do
+ refine(c) do
+ def undefined_refined_public; end
+ def undefined_refined_protected; end
+ def undefined_refined_private; end
+ public :undefined_refined_public
+ protected :undefined_refined_protected
+ private :undefined_refined_private
+ end
+ end
+
+ using m
+
+ assert_equal(false, c.public_method_defined?(:undefined_refined_public), bug10753)
+ assert_equal(false, c.public_method_defined?(:undefined_refined_protected), bug10753)
+ assert_equal(false, c.public_method_defined?(:undefined_refined_private), bug10753)
+
+ assert_equal(false, c.protected_method_defined?(:undefined_refined_public), bug10753)
+ assert_equal(false, c.protected_method_defined?(:undefined_refined_protected), bug10753)
+ assert_equal(false, c.protected_method_defined?(:undefined_refined_private), bug10753)
+
+ assert_equal(false, c.private_method_defined?(:undefined_refined_public), bug10753)
+ assert_equal(false, c.private_method_defined?(:undefined_refined_protected), bug10753)
+ assert_equal(false, c.private_method_defined?(:undefined_refined_private), bug10753)
+ end;
+ end
+
private
def eval_using(mod, s)