|
7 | 7 |
|
8 | 8 | using namespace boost; |
9 | 9 |
|
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 | +{ |
11 | 12 | using namespace ut; |
12 | 13 |
|
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 | +} |
15 | 36 |
|
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; |
25 | 39 |
|
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); |
29 | 44 | }; |
30 | 45 |
|
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); |
36 | 49 | }; |
37 | 50 | }; |
38 | 51 |
|
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); |
55 | 56 | }; |
56 | 57 |
|
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); |
62 | 61 | }; |
63 | 62 | }; |
64 | 63 | }; |
0 commit comments