Jlm
ArgumentTests.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #include <gtest/gtest.h>
7 
8 #include <jlm/rvsdg/graph.hpp>
10 #include <jlm/rvsdg/TestType.hpp>
11 
12 #include <cassert>
13 
17 TEST(ArgumentTests, ArgumentNodeMismatch)
18 {
19  using namespace jlm::rvsdg;
20 
21  // Arrange
22  auto valueType = TestType::createValueType();
23 
24  Graph graph;
25  auto & import = jlm::rvsdg::GraphImport::Create(graph, valueType, "import");
26 
27  auto structuralNode1 = TestStructuralNode::create(&graph.GetRootRegion(), 1);
28  auto structuralNode2 = TestStructuralNode::create(&graph.GetRootRegion(), 2);
29 
30  auto & structuralInput = structuralNode1->addInputOnly(import);
31 
32  // Act & Assert
33  EXPECT_THROW(
34  RegionArgument::Create(*structuralNode2->subregion(0), &structuralInput, valueType),
36 }
37 
38 TEST(ArgumentTests, ArgumentInputTypeMismatch)
39 {
40  using namespace jlm::rvsdg;
41  using namespace jlm::util;
42 
43  // Arrange
44  auto valueType = TestType::createValueType();
45  auto stateType = TestType::createStateType();
46 
47  jlm::rvsdg::Graph rvsdg;
48  auto & x = jlm::rvsdg::GraphImport::Create(rvsdg, valueType, "import");
49 
50  auto structuralNode = TestStructuralNode::create(&rvsdg.GetRootRegion(), 1);
51  auto & structuralInput = structuralNode->addInputOnly(x);
52 
53  // Act & Assert
54  EXPECT_THROW(
55  RegionArgument::Create(*structuralNode->subregion(0), &structuralInput, stateType),
57 }
TEST(ArgumentTests, ArgumentNodeMismatch)
static GraphImport & Create(Graph &graph, std::shared_ptr< const rvsdg::Type > type, std::string name)
Definition: graph.cpp:36
Region & GetRootRegion() const noexcept
Definition: graph.hpp:99
static RegionArgument & Create(rvsdg::Region &region, StructuralInput *input, std::shared_ptr< const rvsdg::Type > type)
Creates region entry argument.
Definition: region.cpp:62
static TestStructuralNode * create(Region *parent, const size_t numSubregions)
Definition: TestNodes.hpp:152
static std::shared_ptr< const TestType > createStateType()
Definition: TestType.cpp:60
static std::shared_ptr< const TestType > createValueType()
Definition: TestType.cpp:67