8 #include <catch2/catch_test_macros.hpp>
18 using namespace nmodl;
19 using namespace visitor;
20 using namespace test_utils;
40 SCENARIO(
"GLOBAL to RANGE variable transformer",
"[visitor][globaltorange]") {
41 GIVEN(
"mod file with GLOBAL variables that are written") {
42 std::string input_nmodl = R
"(
56 auto symtab = ast->get_symbol_table();
57 THEN(
"GLOBAL variables that are written are turned to RANGE") {
59 auto vars = symtab->get_variables_with_properties(NmodlType::range_var);
60 REQUIRE(vars.size() == 3);
63 auto x = symtab->lookup(
"x");
64 REQUIRE(x !=
nullptr);
65 REQUIRE(x->has_any_property(NmodlType::range_var) ==
true);
66 REQUIRE(x->has_any_property(NmodlType::global_var) ==
false);
68 THEN(
"GLOBAL variables that are read only remain GLOBAL") {
69 auto vars = symtab->get_variables_with_properties(NmodlType::global_var);
70 REQUIRE(vars.size() == 1);
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 convert GLOBAL variables to RANGE variables.
Visitor for measuring performance related information
void visit_program(const ast::Program &node) override
visit node of type ast::Program
Concrete visitor for constructing symbol table from AST.
void visit_program(ast::Program &node) override
visit node of type ast::Program
SCENARIO("GLOBAL to RANGE variable transformer", "[visitor][globaltorange]")
std::shared_ptr< ast::Program > run_global_to_var_visitor(const std::string &text)
Visitor to convert GLOBAL variables to RANGE variables.
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
auto get_name(Tag const &tag, int field_index)
Get the nicest available name for the field_index-th instance of Tag.
NmodlType
NMODL variable properties.
encapsulates code generation backend implementations
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
Visitor for measuring performance related information
Auto generated AST classes declaration.
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::parser::UnitDriver driver