Skip to content

Commit 5fedecd

Browse files
committed
feat(tests): duplicate lang suite to run with and without the ir inliner
1 parent a1461c9 commit 5fedecd

2 files changed

Lines changed: 50 additions & 44 deletions

File tree

src/arkreactor/Compiler/IntermediateRepresentation/IRInliner.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,20 @@ namespace Ark::internal
185185
void IRInliner::inlineBlock(const IR::Block& inlinee, IR::Block& destination)
186186
{
187187
if (destination.metadata.addr == 0)
188-
m_logger.debug("Inlining call to '{}' ({}) inside global scope", inlinee.debugName(), inlinee.metadataRepr());
188+
m_logger.info("Inlining call to '{}' ({}) inside global scope", inlinee.debugName(), inlinee.metadataRepr());
189189
else
190-
m_logger.debug("Inlining call to '{}' ({}) inside '{}' @ {}", inlinee.debugName(), inlinee.metadataRepr(), destination.debugName(), destination.metadata.addr);
190+
m_logger.info(
191+
"Inlining call to '{}' ({} from '{}') inside '{}' @ {}, from '{}'",
192+
inlinee.debugName(),
193+
inlinee.metadataRepr(),
194+
inlinee.data.front().filename(),
195+
destination.debugName(),
196+
destination.metadata.addr,
197+
destination.data.front().filename());
191198

192199
if (auto inst = isBuiltinProxy(inlinee); inst.has_value())
193200
{
194-
m_logger.debug(" -> builtin proxy with args ({}, {})", inst->primaryArg(), inst->secondaryArg());
201+
m_logger.info(" -> builtin proxy with args ({}, {})", inst->primaryArg(), inst->secondaryArg());
195202
destination.data.emplace_back(CALL_BUILTIN_WITHOUT_RETURN_ADDRESS, inst->primaryArg(), inst->secondaryArg());
196203
return;
197204
}

tests/unittests/Suites/LangSuite.cpp

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,57 @@
77

88
using namespace boost;
99

10-
ut::suite<"Lang"> lang_suite = [] {
10+
void testResource(Ark::State& state, const bool is_res, const std::string& path, const uint16_t features)
11+
{
1112
using namespace ut;
1213

13-
"[run arkscript unittests]"_test = [] {
14-
Ark::State state({ lib_path, unittests_path });
14+
try
15+
{
16+
const bool ok = mut(state).doFile(is_res ? getResourcePath(path) : path, features);
17+
expect(ok) << fatal << "compilation failed";
18+
}
19+
catch (const Ark::CodeError&)
20+
{
21+
expect(false) << fatal << "encountered an exception while compiling";
22+
}
23+
24+
Ark::VM vm(state);
25+
should("return exit code 0") = [&] {
26+
expect(mut(vm).run() == 0_i);
27+
};
28+
29+
should("have no failures") = [&] {
30+
const auto failure_count = mut(vm).operator[]("failure_count");
31+
expect(failure_count.valueType() == Ark::ValueType::Number &&
32+
failure_count.number() == 0.0)
33+
<< "failure_count = 0\n";
34+
};
35+
}
1536

16-
try
17-
{
18-
const bool ok = mut(state).doFile(getResourcePath("LangSuite/unittests.ark"));
19-
expect(ok) << fatal << "compilation failed";
20-
}
21-
catch (const Ark::CodeError&)
22-
{
23-
expect(false) << fatal << "encountered an exception while compiling";
24-
}
37+
ut::suite<"Lang"> lang_suite = [] {
38+
using namespace ut;
2539

26-
Ark::VM vm(state);
27-
should("return exit code 0") = [&] {
28-
expect(mut(vm).run() == 0_i);
40+
"run arkscript unittests"_test = [] {
41+
"without IR inliner"_test = [] {
42+
Ark::State state({ lib_path, unittests_path });
43+
testResource(state, /* is_res= */ true, "LangSuite/unittests.ark", Ark::DefaultFeatures & ~Ark::FeatureIRInliner);
2944
};
3045

31-
should("have no failures") = [&] {
32-
const auto failure_count = mut(vm).operator[]("failure_count");
33-
expect(failure_count.valueType() == Ark::ValueType::Number &&
34-
failure_count.number() == 0.0)
35-
<< "failure_count = 0\n";
46+
"with IR inliner"_test = [] {
47+
Ark::State state({ lib_path, unittests_path });
48+
testResource(state, /* is_res= */ true, "LangSuite/unittests.ark", Ark::DefaultFeatures);
3649
};
3750
};
3851

39-
"[run arkscript stdlib unittests]"_test = [] {
40-
Ark::State state({ lib_path });
41-
42-
try
43-
{
44-
const bool ok = mut(state).doFile(ARK_TESTS_ROOT "lib/std/tests/all.ark");
45-
expect(ok) << fatal << "compilation failed";
46-
}
47-
catch (const Ark::CodeError&)
48-
{
49-
expect(false) << fatal << "encountered an exception while compiling";
50-
}
51-
52-
Ark::VM vm(state);
53-
should("return exit code 0") = [&] {
54-
expect(mut(vm).run() == 0_i);
52+
"run arkscript stdlib unittests"_test = [] {
53+
"without IR inliner"_test = [] {
54+
Ark::State state({ lib_path });
55+
testResource(state, /* is_res= */ false, ARK_TESTS_ROOT "lib/std/tests/all.ark", Ark::DefaultFeatures & ~Ark::FeatureIRInliner);
5556
};
5657

57-
should("have no failures") = [&] {
58-
const auto failure_count = mut(vm).operator[]("failure_count");
59-
expect(failure_count.valueType() == Ark::ValueType::Number &&
60-
failure_count.number() == 0.0)
61-
<< "failure_count = 0\n";
58+
"with IR inliner"_test = [] {
59+
Ark::State state({ lib_path });
60+
testResource(state, /* is_res= */ false, ARK_TESTS_ROOT "lib/std/tests/all.ark", Ark::DefaultFeatures);
6261
};
6362
};
6463
};

0 commit comments

Comments
 (0)