![Logo](logo.png) |
User Guide
|
Go to the documentation of this file.
8 #include <catch2/catch_test_macros.hpp>
19 using namespace nmodl;
20 using namespace visitor;
22 using namespace test_utils;
34 SymtabVisitor().visit_program(*ast);
35 NeuronSolveVisitor().visit_program(*ast);
36 SolveBlockVisitor().visit_program(*ast);
37 std::stringstream stream;
38 NmodlPrintVisitor(stream).visit_program(*ast);
41 CheckParentVisitor().check_ast(*ast);
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") {
49 std::string nmodl_text = R
"(
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") {
81 std::string nmodl_text = R
"(
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") {
130 std::string nmodl_text = R
"(
136 SOLVE myfunc METHOD derivimplicit
139 PROCEDURE myfunc() {}
141 THEN("A runtime error should be thrown") {
Class that binds all pieces together for parsing nmodl file.
Replace solve block statements with actual solution node in the AST.
std::string reindent_text(const std::string &text, int indent_level)
Reindent nmodl text for text-to-text comparison.
encapsulates code generation backend implementations
TEST_CASE("Solve ODEs using legacy NeuronSolveVisitor", "[visitor][solver]")
Auto generated AST classes declaration.
nmodl::parser::UnitDriver driver
bool parse_string(const std::string &input)
parser Units provided as string (used for testing)
Visitor that solves ODEs using old solvers of NEURON
Visitor for checking parents of ast nodes
std::string run_solve_block_visitor(const std::string &text)
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.