2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2012-12-04 21:37:41 -05:00
|
|
|
require_relative 'base'
|
|
|
|
require 'tempfile'
|
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
class TestMkmfHaveMacro < TestMkmf
|
|
|
|
MACRO_NAME = "RUBY_MKMFTEST_FOOBAR"
|
2012-12-04 21:37:41 -05:00
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
def test_have_macro_opt
|
|
|
|
assert_equal(true, have_macro(MACRO_NAME, nil, "-D#{MACRO_NAME}"), MKMFLOG)
|
|
|
|
end
|
2012-12-04 21:37:41 -05:00
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
def test_have_macro_header
|
|
|
|
Tempfile.create(%w"test_mkmf .h", ".") do |tmp|
|
|
|
|
tmp.puts("#undef #{MACRO_NAME}")
|
|
|
|
tmp.puts("#define #{MACRO_NAME} 1")
|
|
|
|
tmp.close
|
|
|
|
base = File.basename(tmp.path)
|
|
|
|
assert_equal(true, have_macro(MACRO_NAME, base, "-I."), MKMFLOG)
|
2012-12-04 21:37:41 -05:00
|
|
|
end
|
2022-04-22 16:01:43 -04:00
|
|
|
end
|
2012-12-04 21:37:41 -05:00
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
def test_not_have_macro_opt
|
|
|
|
assert_equal(false, have_macro(MACRO_NAME, nil, "-U#{MACRO_NAME}"), MKMFLOG)
|
|
|
|
end
|
2012-12-04 21:37:41 -05:00
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
def test_not_have_macro_header
|
|
|
|
Tempfile.create(%w"test_mkmf .h", ".") do |tmp|
|
|
|
|
tmp.puts("#undef #{MACRO_NAME}")
|
|
|
|
tmp.close
|
|
|
|
base = File.basename(tmp.path)
|
|
|
|
assert_equal(false, have_macro(MACRO_NAME, base, "-I."), MKMFLOG)
|
2012-12-04 21:37:41 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|