blob: 959d72a3eadbe91ed5c6ec726282202cc5ea83d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <catch2/catch_test_macros.hpp>
#include <willow/IR/Context.h>
#include <willow/IR/Module.h>
#include <willow/IR/Verifier.h>
#include <willow/IR/Diagnostic.h>
#include <willow/IR/DiagnosticEngine.h>
#include <willow/IR/Function.h>
using namespace willow;
TEST_CASE("valid modules", "[verifier]") {
WillowContext ctx;
std::vector<Diagnostic> diags;
DiagnosticEngine eng(
[&](Diagnostic d) { diags.push_back(std::move(d)); });
auto &m = *ctx.addModule("test");
SECTION("empty module") {
REQUIRE(succeeded(verifyModule(ctx, m, eng)));
REQUIRE(diags.empty());
}
}
TEST_CASE("valid function", "[verifier]") {
WillowContext ctx;
std::vector<Diagnostic> diags;
DiagnosticEngine eng(
[&](Diagnostic d) { diags.push_back(std::move(d)); });
auto &m = *ctx.addModule("test");
Type fty = ctx.types().FunctionType(ctx.types().VoidType(), {});
auto &fn = *m.emplaceFunction("fn", &m, fty);
REQUIRE(succeeded(verifyFunction(ctx, fn, eng)));
REQUIRE(diags.empty());
}
TEST_CASE("invalid basic block", "[verifier]") {
WillowContext ctx;
std::vector<Diagnostic> diags;
DiagnosticEngine eng(
[&](Diagnostic d) { diags.push_back(std::move(d)); });
auto &m = *ctx.addModule("test");
Type fty = ctx.types().FunctionType(ctx.types().VoidType(), {});
auto &fn = *m.emplaceFunction("fn", &m, fty);
// TODO
}
|