8 #include <catch2/catch_test_macros.hpp>
19 using namespace nmodl;
20 using namespace visitor;
22 using namespace test_utils;
37 std::stringstream stream;
47 SCENARIO(
"NeuronSolveVisitor visitor solves different ODE types") {
48 GIVEN(
"Derivative block with cnexp method in breakpoint block") {
51 SOLVE states METHOD cnexp
61 std::string output_nmodl = R"(
63 SOLVE states METHOD cnexp
67 m = m+(1.0-exp(dt*((((-1.0)))/mTau[0])))*(-(((mInf))/mTau[0])/((((-1.0)))/mTau[0])-m)
68 h = h+(1.0-exp(dt*((((-1.0)))/hTau)))*(-(((hInf))/hTau)/((((-1.0)))/hTau)-h)
73 THEN("ODEs get replaced with solution") {
77 REQUIRE(
result == expected_result);
81 GIVEN(
"Derivative block without any solve method specification") {
89 std::string output_nmodl = R"(
96 THEN("ODEs don't get solved") {
100 REQUIRE(
result == expected_result);
104 GIVEN(
"Derivative block with non-cnexp method in breakpoint block") {
107 SOLVE states METHOD derivimplicit
116 std::string output_nmodl = R"(
118 SOLVE states METHOD derivimplicit
127 THEN("ODEs don't get solved but state variables get replaced with Dstate ") {
131 REQUIRE(
result == expected_result);
135 GIVEN(
"Derivative block with ODEs that needs non-cnexp method to solve") {
138 SOLVE states METHOD cnexp
142 A_AMPA' = tau_r_AMPA/A_AMPA
146 std::string output_nmodl = R"(
148 SOLVE states METHOD cnexp
152 A_AMPA' = tau_r_AMPA/A_AMPA
156 THEN("ODEs don't get replaced as cnexp is not possible") {
160 REQUIRE(
result == expected_result);
Visitor for checking parents of ast nodes
Class that binds all pieces together for parsing nmodl file.
Visitor that solves ODEs using old solvers of NEURON
void visit_program(ast::Program &node) override
visit node of type ast::Program
Visitor for printing AST back to NMODL
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
Visitor for checking parents of ast nodes
int check_ast(const ast::Ast &node)
A small wrapper to have a nicer call in parser.cpp.
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
SCENARIO("NeuronSolveVisitor visitor solves different ODE types")
std::string run_cnexp_solve_visitor(const std::string &text)
Visitor that solves ODEs using old solvers of NEURON
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
Auto generated AST classes declaration.
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::parser::UnitDriver driver