8 #include <catch2/catch_test_macros.hpp>
19 using namespace nmodl;
20 using namespace visitor;
22 using namespace test_utils;
35 SymtabVisitor().visit_program(*ast);
36 NeuronSolveVisitor().visit_program(*ast);
37 std::stringstream stream;
38 NmodlPrintVisitor(stream).visit_program(*ast);
41 CheckParentVisitor().check_ast(*ast);
47 SCENARIO(
"NeuronSolveVisitor visitor solves different ODE types") {
48 GIVEN(
"Derivative block with cnexp method in breakpoint block") {
49 std::string nmodl_text = R
"(
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") {
82 std::string nmodl_text = R
"(
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") {
105 std::string nmodl_text = R
"(
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") {
136 std::string nmodl_text = R
"(
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);