ruby-changes:71371
From: John <ko1@a...>
Date: Sat, 12 Mar 2022 03:36:33 +0900 (JST)
Subject: [ruby-changes:71371] 83fabfccf5 (master): Add test for protected methods on module included
https://git.ruby-lang.org/ruby.git/commit/?id=83fabfccf5 From 83fabfccf5d45312325bab83de2cf62ea54fa020 Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Thu, 10 Mar 2022 12:19:40 -0800 Subject: Add test for protected methods on module included --- test/ruby/test_module.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e744121718..6bbe168348 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -756,6 +756,25 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L756 assert_equal([:m1, :m0, :m, :sc, :m1, :m0, :c], sc.new.m) end + def test_protected_include_into_included_module + m1 = Module.new do + def other_foo(other) + other.foo + end + + protected + def foo + :ok + end + end + m2 = Module.new + c1 = Class.new { include m2 } + c2 = Class.new { include m2 } + m2.include(m1) + + assert_equal :ok, c1.new.other_foo(c2.new) + end + def test_instance_methods assert_equal([:user, :user2], User.instance_methods(false).sort) assert_equal([:user, :user2, :mixin].sort, User.instance_methods(true).sort) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/