2012-12-04 21:37:41 -05:00
|
|
|
require_relative 'base'
|
|
|
|
require 'tempfile'
|
|
|
|
|
|
|
|
class TestMkmf
|
2012-12-05 01:30:34 -05:00
|
|
|
class TestHaveMacro < TestMkmf
|
2012-12-04 21:37:41 -05:00
|
|
|
MACRO_NAME = "RUBY_MKMFTEST_FOOBAR"
|
|
|
|
|
|
|
|
def test_have_macro_opt
|
|
|
|
assert_equal(true, have_macro(MACRO_NAME, nil, "-D#{MACRO_NAME}"), MKMFLOG)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_have_macro_header
|
|
|
|
Tempfile.open(%w"test_mkmf .h", ".") do |tmp|
|
|
|
|
tmp.puts("#undef #{MACRO_NAME}")
|
|
|
|
tmp.puts("#define #{MACRO_NAME} 1")
|
|
|
|
tmp.close
|
2013-01-20 23:53:43 -05:00
|
|
|
base = File.basename(tmp.path)
|
2012-12-04 21:37:41 -05:00
|
|
|
assert_equal(true, have_macro(MACRO_NAME, base, "-I."), MKMFLOG)
|
2013-03-23 13:16:21 -04:00
|
|
|
tmp.close(true)
|
2012-12-04 21:37:41 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_not_have_macro_opt
|
|
|
|
assert_equal(false, have_macro(MACRO_NAME, nil, "-U#{MACRO_NAME}"), MKMFLOG)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_not_have_macro_header
|
|
|
|
Tempfile.open(%w"test_mkmf .h", ".") do |tmp|
|
|
|
|
tmp.puts("#undef #{MACRO_NAME}")
|
|
|
|
tmp.close
|
2013-01-20 23:53:43 -05:00
|
|
|
base = File.basename(tmp.path)
|
2012-12-04 21:37:41 -05:00
|
|
|
assert_equal(false, have_macro(MACRO_NAME, base, "-I."), MKMFLOG)
|
2013-03-23 13:16:21 -04:00
|
|
|
tmp.close(true)
|
2012-12-04 21:37:41 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|