Fix remaining failing tests

This commit is contained in:
Tyler Wilding
2020-10-09 19:37:09 -04:00
parent 76bede157d
commit f712c615ce
8 changed files with 64 additions and 59 deletions
+39
View File
@@ -77,3 +77,42 @@ TEST_F(FunctionTests, Anonymous) {
runner.run_static_test(env, testCategory, "declare-inline.static.gc", {"32\n"});
runner.run_static_test(env, testCategory, "lambda-1.static.gc", {"2\n"});
}
TEST_F(FunctionTests, InlineIsInline) {
auto code = compiler.get_goos().reader.read_from_file(
{"test/goalc/source_templates/functions/declare-inline.static.gc"});
auto compiled = compiler.compile_object_file("test-code", code, true);
EXPECT_EQ(compiled->functions().size(), 2);
auto& ir = compiled->top_level_function().code();
bool got_mult = false;
for (auto& x : ir) {
EXPECT_EQ(dynamic_cast<IR_FunctionCall*>(x.get()), nullptr);
auto as_im = dynamic_cast<IR_IntegerMath*>(x.get());
if (as_im) {
EXPECT_EQ(as_im->get_kind(), IntegerMathKind::IMUL_32);
got_mult = true;
}
}
EXPECT_TRUE(got_mult);
}
TEST_F(FunctionTests, AllowInline) {
auto code = compiler.get_goos().reader.read_from_file(
{"test/goalc/source_templates/functions/inline-call.static.gc"});
auto compiled = compiler.compile_object_file("test-code", code, true);
EXPECT_EQ(compiled->functions().size(), 2);
auto& ir = compiled->top_level_function().code();
int got_mult = 0;
int got_call = 0;
for (auto& x : ir) {
if (dynamic_cast<IR_FunctionCall*>(x.get())) {
got_call++;
}
auto as_im = dynamic_cast<IR_IntegerMath*>(x.get());
if (as_im && as_im->get_kind() == IntegerMathKind::IMUL_32) {
got_mult++;
}
}
EXPECT_EQ(got_mult, 1);
EXPECT_EQ(got_call, 1);
}