8 #include <catch2/catch_test_macros.hpp>
15 using namespace nmodl;
16 using namespace visitor;
23 const std::string& variable) {
27 SCENARIO(
"Searching for variable name using VarUsageVisitor",
"[visitor][var_usage]") {
28 auto to_ast = [](
const std::string&
text) {
33 GIVEN(
"A simple NMODL block") {
45 auto node = ast->get_blocks().front();
47 WHEN(
"Looking for existing variable") {
48 THEN(
"Can find variables") {
55 WHEN(
"Looking for missing variable") {
56 THEN(
"Can not find variable") {
63 GIVEN(
"A nested NMODL block") {
65 NET_RECEIVE (weight,weight_AMPA, weight_NMDA, R){
68 weight_NMDA = weight * NMDA_ratio
80 auto node = ast->get_blocks().front();
82 WHEN(
"Looking for existing variable in outer block") {
83 THEN(
"Can find variables") {
89 WHEN(
"Looking for existing variable in inner block") {
90 THEN(
"Can find variables") {
Class that binds all pieces together for parsing nmodl file.
Check if variable is used in given block.
bool variable_used(const ast::Node &node, std::string name)
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
encapsulates code generation backend implementations
static Node * node(Object *)
Auto generated AST classes declaration.
nmodl::parser::UnitDriver driver
static bool run_var_usage_visitor(const std::shared_ptr< ast::Node > &node, const std::string &variable)
SCENARIO("Searching for variable name using VarUsageVisitor", "[visitor][var_usage]")
Check if variable is used in given block.