DialectTest.cpp
1.24 KB
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
//===- DialectTest.cpp - Dialect unit tests -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/IR/Dialect.h"
#include "gtest/gtest.h"
using namespace mlir;
using namespace mlir::detail;
namespace {
struct TestDialect : public Dialect {
static StringRef getDialectNamespace() { return "test"; };
TestDialect(MLIRContext *context)
: Dialect(getDialectNamespace(), context, TypeID::get<TestDialect>()) {}
};
struct AnotherTestDialect : public Dialect {
static StringRef getDialectNamespace() { return "test"; };
AnotherTestDialect(MLIRContext *context)
: Dialect(getDialectNamespace(), context,
TypeID::get<AnotherTestDialect>()) {}
};
TEST(DialectDeathTest, MultipleDialectsWithSameNamespace) {
MLIRContext context(false);
// Registering a dialect with the same namespace twice should result in a
// failure.
context.loadDialect<TestDialect>();
ASSERT_DEATH(context.loadDialect<AnotherTestDialect>(), "");
}
} // end namespace