//===- 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()) {} }; struct AnotherTestDialect : public Dialect { static StringRef getDialectNamespace() { return "test"; }; AnotherTestDialect(MLIRContext *context) : Dialect(getDialectNamespace(), context, TypeID::get()) {} }; TEST(DialectDeathTest, MultipleDialectsWithSameNamespace) { MLIRContext context; // Registering a dialect with the same namespace twice should result in a // failure. context.loadDialect(); ASSERT_DEATH(context.loadDialect(), ""); } } // end namespace