8 #include <catch2/catch_test_macros.hpp>
19 using namespace nmodl;
20 using namespace visitor;
22 using namespace test_utils;
37 std::stringstream stream;
46 TEST_CASE(
"Solve ODEs using legacy NeuronSolveVisitor",
"[visitor][solver]") {
47 SECTION(
"SolveBlock add NrnState block") {
48 GIVEN(
"Breakpoint block with single solve block in breakpoint") {
51 SOLVE states METHOD cnexp
59 std::string output_nmodl = R"(
61 SOLVE states METHOD cnexp
65 m = m+(1.0-exp(dt*((((-1.0)))/mTau)))*(-(((mInf))/mTau)/((((-1.0)))/mTau)-m)
68 NRN_STATE SOLVE states METHOD cnexp{
69 m = m+(1.0-exp(dt*((((-1.0)))/mTau)))*(-(((mInf))/mTau)/((((-1.0)))/mTau)-m)
74 THEN("Single NrnState block gets added") {
80 GIVEN(
"Breakpoint block with two solve block in breakpoint") {
83 SOLVE state1 METHOD cnexp
84 SOLVE state2 METHOD cnexp
96 std::string output_nmodl = R"(
98 SOLVE state1 METHOD cnexp
99 SOLVE state2 METHOD cnexp
103 m = m+(1.0-exp(dt*((((-1.0)))/mTau)))*(-(((mInf))/mTau)/((((-1.0)))/mTau)-m)
107 h = h+(1.0-exp(dt*((((-1.0)))/mTau)))*(-(((mInf))/mTau)/((((-1.0)))/mTau)-h)
110 NRN_STATE SOLVE state1 METHOD cnexp{
111 m = m+(1.0-exp(dt*((((-1.0)))/mTau)))*(-(((mInf))/mTau)/((((-1.0)))/mTau)-m)
113 SOLVE state2 METHOD cnexp{
114 h = h+(1.0-exp(dt*((((-1.0)))/mTau)))*(-(((mInf))/mTau)/((((-1.0)))/mTau)-h)
119 THEN("NrnState blok combining multiple solve nodes added") {
127 TEST_CASE(
"Throw errors on invalid methods",
"[visitor][solver]") {
128 SECTION(
"PROCEDURE cannot be SOLVEd with derivimplicit METHOD") {
129 GIVEN(
"Breakpoint block with a PROCEDURE being solved using the derivimplcit METHOD") {
136 SOLVE myfunc METHOD derivimplicit
139 PROCEDURE myfunc() {}
141 THEN("A runtime error should be thrown") {
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
Replace solve block statements with actual solution node in the AST.
void visit_program(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
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.
std::string run_solve_block_visitor(const std::string &text)
TEST_CASE("Solve ODEs using legacy NeuronSolveVisitor", "[visitor][solver]")
Replace solve block statements with actual solution node in the AST.
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::parser::UnitDriver driver