8 #include <catch2/catch_test_macros.hpp>
16 using namespace nmodl;
17 using namespace visitor;
22 std::pair<std::string, std::pair<std::string, std::unordered_set<std::string>>>
29 SCENARIO(
"Get node name with index TestVisitor",
"[visitor][node_index]") {
30 auto to_ast = [](
const std::string&
text) {
35 GIVEN(
"A simple NMODL block") {
36 std::string nmodl_text_a = R
"(
41 SOLVE states METHOD euler
47 std::string nmodl_text_b = R"(
49 SOLVE states STEADYSTATE sparse
56 WHEN("Get node name with index") {
57 THEN(
"Get node name with index") {
58 auto ast = to_ast(nmodl_text_a);
59 std::unordered_set<std::string> vars{
"mInf",
"mTau"};
60 std::string
var(
"m[0]");
61 auto expect = std::make_pair(
var, vars);
64 REQUIRE(result_name ==
var);
65 REQUIRE(result_dependencies.first == expect.first);
66 REQUIRE(result_dependencies.second == expect.second);
68 THEN(
"Get dependencies") {
69 auto ast = to_ast(nmodl_text_b);
70 std::unordered_set<std::string> vars{
"m",
"h"};
72 auto expect = std::make_pair(
var, vars);
75 REQUIRE(result_dependencies.first == expect.first);
76 REQUIRE(result_dependencies.second == expect.second);
Represents top level AST node for whole NMODL input.
Class that binds all pieces together for parsing nmodl file.
Get node name with indexed for the IndexedName node and the dependencies of DiffEqExpression node.
void visit_program(ast::Program &node) override
visit node of type ast::Program
std::pair< std::string, std::unordered_set< std::string > > get_dependencies()
get the attribute dependencies
std::string get_indexed_name()
get the attribute indexed_name
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
Get node name with indexed for the IndexedName node and the dependencies of DiffEqExpression node.
double var(InputIterator begin, InputIterator end)
encapsulates code generation backend implementations
SCENARIO("Get node name with index TestVisitor", "[visitor][node_index]")
std::pair< std::string, std::pair< std::string, std::unordered_set< std::string > > > get_indexedname_dependencies(ast::Program &node)
static Node * node(Object *)
Auto generated AST classes declaration.
nmodl::parser::UnitDriver driver
Utility functions for visitors implementation.