[Kst] kdeextragear-2/kst/tests
George Staikos
staikos at kde.org
Mon Nov 22 18:28:45 CET 2004
CVS commit by staikos:
Bug in the optimizer - it doesn't optimize the toplevel node in the tree. Not
really much of an issue, but this fixes my coverage calculations, and it should
be fixed one day.
M +13 -2 testeqparser.cpp 1.5
--- kdeextragear-2/kst/tests/testeqparser.cpp #1.4:1.5
@@ -23,4 +23,6 @@ double INF = 1.0/0.0;
#endif
+bool optimizerFailed = false;
+
bool doTest(const char *equation, double x, double result, const double tol = 0.00000000001) {
yy_scan_string(equation);
@@ -28,11 +30,20 @@ bool doTest(const char *equation, double
if (rc == 0) {
Equation::Node *eq = static_cast<Equation::Node*>(ParsedEquation);
+ ParsedEquation = 0L;
Equation::Context ctx;
ctx.sampleCount = 2;
ctx.noPoint = NOPOINT;
+ ctx.x = x;
Equation::FoldVisitor vis(&ctx, eq);
+ if (eq->isConst()) {
+ if (!optimizerFailed) {
+ optimizerFailed = true;
+ printf("Optimizer bug: found an unoptimized const equation. Optimizing for coverage purposes.\n");
+ }
+ double v = eq->value(&ctx);
+ delete eq;
+ eq = new Equation::Number(v);
+ }
eq->update(-1, &ctx);
- ParsedEquation = 0L;
- ctx.x = x;
double v = eq->value(&ctx);
delete eq;
More information about the Kst
mailing list