8 #include <catch2/catch_test_macros.hpp>
18 using namespace nmodl;
19 using namespace visitor;
20 using namespace test_utils;
33 SymtabVisitor().visit_program(*ast);
34 PerfVisitor().visit_program(*ast);
35 GlobalToRangeVisitor(*ast).visit_program(*ast);
36 SymtabVisitor().visit_program(*ast);
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);