[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/kalgebra
From: Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date: 2008-04-10 11:34:05
Message-ID: 1207827245.590402.9613.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 795457 by apol:
- Fixed a bug related to the piecewise command. Thanks to Oscar Martinez for notifying :)
M +5 -1 analitza/analitza.cpp
M +19 -4 tests/analitzatest.cpp
M +1 -0 tests/exptest.cpp
--- trunk/KDE/kdeedu/kalgebra/analitza/analitza.cpp #795456:795457
@@ -473,7 +473,7 @@
}
delete ret;
} else {
- //it is an otherwise
+ //it is an otherwise
if(otherwise)
m_err << i18n("Too much <em>otherwise</em> parameters");
else
@@ -490,6 +490,9 @@
if(r)
ret=calc(r);
+ else
+ ret=new Cn(0.);
+ Q_ASSERT(ret);
return ret;
}
@@ -516,6 +519,7 @@
ret=new Cn(0.);
delete o;
}
+ Q_ASSERT(ret);
return ret;
}
--- trunk/KDE/kdeedu/kalgebra/tests/analitzatest.cpp #795456:795457
@@ -104,10 +104,10 @@
QTest::newRow("multiplication") << "x*x" << "x^2";
QTest::newRow("undefined function call") << "f(2)" << "f(2)";
QTest::newRow("--simplification") << "-(-x)" << "x";
- QTest::newRow("unneeded --simplification") << "-(x-x)" << "0";
- QTest::newRow("after simp(minus) --simplification") << "-(x-x-x)" << "x";
- QTest::newRow("and") << "and(gt(6,5), lt(4,5))" << "true";
- QTest::newRow("or") << "or(gt(6,5), lt(6,5))" << "true";
+ QTest::newRow("unneeded --simplification") << "-(x-x)" << "0";
+ QTest::newRow("after simp(minus) --simplification") << "-(x-x-x)" << "x";
+ QTest::newRow("and") << "and(gt(6,5), lt(4,5))" << "true";
+ QTest::newRow("or") << "or(gt(6,5), lt(6,5))" << "true";
QTest::newRow("sum") << "sum(n->1..99, n)" << "4950";
QTest::newRow("sum times simplification") << "sum(n->0..99, n*x)" << "4950*x";
@@ -391,6 +391,8 @@
QTest::newRow("empty math") << "<math />";
QTest::newRow("selector overflow") << "selector(9, vector{1,2})";
QTest::newRow("selector underflow") << "selector(0, vector{1,2})";
+ QTest::newRow("simple piecewise") << "piecewise { eq(pi,0)? 3, eq(pi, pi)?33 }";
+ QTest::newRow("oscarmartinez piecewise") << "piecewise { gt(x,23)?a }";
QTest::newRow("wrong func") << "xsin(x)";
}
@@ -404,6 +406,19 @@
a->setExpression(e);
QString str=a->calculate().toString();
str=a->evaluate().toString();
+
+ //We don't want it to crash, so we try to
+ for(int i=0; i<expression.size(); i++)
+ {
+ QString aux=expression.left(i);
+ QString aux1=expression.right(i);
+
+ Expression e1(aux, false);
+ Expression e2(aux, true);
+
+ Expression e3(aux1, false);
+ Expression e4(aux1, true);
+ }
}
#include "analitzatest.moc"
--- trunk/KDE/kdeedu/kalgebra/tests/exptest.cpp #795456:795457
@@ -115,6 +115,7 @@
QTest::newRow("stack killing") << "k+++k" << false;
QTest::newRow("more stack killing") << "k-++k" << false;
+ QTest::newRow("omartinez bug") << "piecewise { gt(x,23)?a }" << true;
}
void ExpTest::testCorrection()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic