2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2010-12-10 04:11:48 -05:00
|
|
|
require_relative 'base'
|
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
class TestMkmfSignedness < TestMkmf
|
|
|
|
def test_typeof_builtin
|
|
|
|
bug4144 = '[ruby-dev:42731]'
|
|
|
|
[["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
|
|
|
|
%w[short int long].each do |type|
|
|
|
|
assert_equal(expect.to_i, mkmf {check_signedness(signed+type)}, mkmflog(bug4144))
|
2010-12-10 04:11:48 -05:00
|
|
|
end
|
|
|
|
end
|
2022-04-22 16:01:43 -04:00
|
|
|
end
|
2010-12-10 04:11:48 -05:00
|
|
|
|
2022-04-22 16:01:43 -04:00
|
|
|
def test_typeof_typedef
|
|
|
|
[["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
|
|
|
|
%w[short int long].each do |type|
|
|
|
|
open("confdefs.h", "w") {|f|
|
|
|
|
f.puts "typedef #{signed}#{type} test1_t;"
|
|
|
|
}
|
|
|
|
$defs.clear
|
|
|
|
assert_equal(expect.to_i, mkmf {check_signedness("test1_t", "confdefs.h")}, MKMFLOG)
|
|
|
|
assert_include($defs, "-DSIGNEDNESS_OF_TEST1_T=#{expect}")
|
2010-12-10 04:11:48 -05:00
|
|
|
end
|
|
|
|
end
|
2022-04-22 16:01:43 -04:00
|
|
|
ensure
|
|
|
|
File.unlink("confdefs.h")
|
2010-12-10 04:11:48 -05:00
|
|
|
end
|
|
|
|
end
|