MCPcopy Create free account
hub / github.com/IBAMR/IBAMR / TestOptimizer

Method TestOptimizer

ibtk/contrib/muparser/src/muParserTest.cpp:136–188  ·  view source on GitHub ↗

---------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

134
135 //---------------------------------------------------------------------------------------------
136 int ParserTester::TestOptimizer()
137 {
138 int iStat = 0;
139 mu::console() << _T("testing optimizer...");
140
141 // Test RemoveVar
142 Parser p;
143 try
144 {
145 // test for #93 (https://github.com/beltoforion/muparser/issues/93)
146 // expected bytecode is:
147 // VAL, FUN
148 {
149 p.DefineFun(_T("unoptimizable"), f1of1, false);
150 p.SetExpr(_T("unoptimizable(1)"));
151 p.Eval();
152
153 auto& bc = p.GetByteCode();
154 const SToken* tok = bc.GetBase();
155 if (bc.GetSize() != 2 && tok[1].Cmd != cmFUNC)
156 {
157 mu::console() << _T("#93 an unoptimizable expression was optimized!") << endl;
158 iStat += 1;
159 }
160 }
161
162 {
163 p.ClearFun();
164 p.DefineFun(_T("unoptimizable"), f1of1, true);
165 p.SetExpr(_T("unoptimizable(1)"));
166 p.Eval();
167
168 auto& bc = p.GetByteCode();
169 const SToken* tok = bc.GetBase();
170 if (bc.GetSize() != 1 && tok[0].Cmd != cmVAL)
171 {
172 mu::console() << _T("#93 optimizer error") << endl;
173 iStat += 1;
174 }
175 }
176 }
177 catch (...)
178 {
179 iStat += 1; // this is not supposed to happen
180 }
181
182 if (iStat == 0)
183 mu::console() << _T("passed") << endl;
184 else
185 mu::console() << _T("\n failed with ") << iStat << _T(" errors") << endl;
186
187 return iStat;
188 }
189
190 //---------------------------------------------------------------------------------------------
191 int ParserTester::TestStrArg()

Callers

nothing calls this directly

Calls 3

SetExprMethod · 0.80
EvalMethod · 0.80
ClearFunMethod · 0.80

Tested by

no test coverage detected