8 #include <catch2/catch_test_macros.hpp>
9 #include <catch2/matchers/catch_matchers_string.hpp>
20 using namespace nmodl;
21 using namespace visitor;
22 using namespace test_utils;
35 throw std::runtime_error(
"Semantic analysis failed");
42 SCENARIO(
"State discontinuity in a NET_RECEIVE block",
"[visitor][state_discontinuity]") {
43 GIVEN(
"A call to state_discontinuity") {
46 state_discontinuity(A, B)
49 std::string expected = R"(
55 THEN("Convert it to A = B") {
62 SCENARIO(
"State discontinuity outside of a NET_RECEIVE block",
"[visitor][state_discontinuity]") {
63 GIVEN(
"A call to state_discontinuity") {
66 state_discontinuity(A, B)
69 THEN("Leave it as-is") {
76 SCENARIO(
"State discontinuity call contains invalid arguments",
"[visitor][state_discontinuity]") {
77 GIVEN(
"A call to state_discontinuity with no args") {
83 THEN("Raise an error") {
87 GIVEN(
"A call to state_discontinuity with 1 arg") {
90 state_discontinuity(A)
93 THEN("Raise an error") {
97 GIVEN(
"A call to state_discontinuity with 3 args") {
100 state_discontinuity(A, B, C)
103 THEN("Raise an error") {
107 GIVEN(
"A call to state_discontinuity with first arg a compound expression") {
110 state_discontinuity(A + 1, B)
113 THEN("Raise an error") {
Class that binds all pieces together for parsing nmodl file.
void visit_program(ast::Program &node) override
visit node of type ast::Program
Visitor to check some semantic rules on the AST
bool check(const ast::Program &node)
Visitor used for replacing literal calls to state_discontinuity in a NET_RECEIVE block.
Concrete visitor for constructing symbol table from AST.
void visit_program(ast::Program &node) override
visit node of type ast::Program
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
std::string reindent_text(const std::string &text, int indent_level)
Reindent nmodl text for text-to-text comparison.
encapsulates code generation backend implementations
std::string to_nmodl(const ast::Ast &node, const std::set< ast::AstNodeType > &exclude_types)
Given AST node, return the NMODL string representation.
Auto generated AST classes declaration.
Visitor to check some semantic rules on the AST
auto run_state_discontinuity_visitor(const std::string &text)
SCENARIO("State discontinuity in a NET_RECEIVE block", "[visitor][state_discontinuity]")
Visitor used for replacing literal calls to state_discontinuity in a NET_RECEIVE block.
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::parser::UnitDriver driver
Utility functions for visitors implementation.