Make the mkmf methods private in the global [Bug #16896]

This commit is contained in:
Nobuyoshi Nakada 2020-07-12 00:09:04 +09:00
parent d99d96cc6d
commit c2a6295ec0
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6
2 changed files with 21 additions and 1 deletions

View File

@ -2822,7 +2822,12 @@ realclean: distclean
end
end
include MakeMakefile
# MakeMakefile::Global = #
m = Module.new {
include(MakeMakefile)
private(*MakeMakefile.public_instance_methods(false))
}
include m
if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
END {mkmf_failed($0)}

15
test/mkmf/test_mkmf.rb Normal file
View File

@ -0,0 +1,15 @@
# frozen_string_literal: false
require 'test/unit'
require 'mkmf'
class TestMkmf < Test::Unit::TestCase
class TestGlobal < TestMkmf
main = TOPLEVEL_BINDING.receiver
MakeMakefile.public_instance_methods(false).each do |m|
define_method(:"test_global_#{m}") do
assert_respond_to(main, [m, true])
assert_not_respond_to(main, [m, false])
end
end
end
end