1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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