mirror of
https://github.com/exaloop/codon.git
synced 2025-06-03 15:03:52 +08:00
28 lines
760 B
C++
28 lines
760 B
C++
#include "test.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "codon/util/fmt/format.h"
|
|
|
|
using namespace codon::ir;
|
|
|
|
TEST_F(SIRCoreTest, ConstTypeQueryAndReplace) {
|
|
auto *node = module->Nr<IntConst>(1, module->getIntType());
|
|
ASSERT_EQ(module->getIntType(), node->getType());
|
|
|
|
auto usedTypes = node->getUsedTypes();
|
|
ASSERT_EQ(1, usedTypes.size());
|
|
ASSERT_EQ(module->getIntType(), usedTypes[0]);
|
|
ASSERT_EQ(1, node->replaceUsedType(module->getIntType(), module->getIntType()));
|
|
}
|
|
|
|
TEST_F(SIRCoreTest, ConstCloning) {
|
|
auto VALUE = 1;
|
|
auto *node = module->Nr<IntConst>(VALUE, module->getIntType());
|
|
auto *clone = cast<IntConst>(cv->clone(node));
|
|
|
|
ASSERT_TRUE(clone);
|
|
ASSERT_EQ(VALUE, clone->getVal());
|
|
ASSERT_EQ(module->getIntType(), clone->getType());
|
|
}
|