[Kst] kdeextragear-2/kst/tests

George Staikos staikos at kde.org
Mon Nov 22 18:17:11 CET 2004


CVS commit by staikos: 

More testcases, including another failure: !NOPOINT (aka !NAN) gives false, but
I think it should give true.

58.12% of 394 source lines executed in file ../../kst/kst/enodes.cpp
94.52% of 73 source lines executed in file ../../kst/kst/eparse.y
44.64% of 56 source lines executed in file ../../kst/kst/escan.l


  M +39 -5     testeqparser.cpp   1.4


--- kdeextragear-2/kst/tests/testeqparser.cpp  #1.3:1.4
@@ -30,4 +30,5 @@ bool doTest(const char *equation, double
                 Equation::Context ctx;
                 ctx.sampleCount = 2;
+                ctx.noPoint = NOPOINT;
                 Equation::FoldVisitor vis(&ctx, eq);
                 eq->update(-1, &ctx);
@@ -73,4 +74,7 @@ int main() {
         test("x^2       ", -1.0, 1.0);
         test("x^2       +       x^2", -1.0, 2.0);
+        test("y", 0.0, NOPOINT);
+        test("foo()", 0.0, NOPOINT);
+        test("foo(1.0, 2.0, 3.0)", 0.0, NOPOINT);
 
         // Order of evaluation and parser issues
@@ -103,9 +107,9 @@ int main() {
 
         // Functions
-        test("sin()", 0.0, 0.0);
+        test("sin()", 0.0, NOPOINT);
         test("sin(0.0)", 0.0, 0.0);
         test("sin(3.14159265358979323)", 0.0, 0.0);
         test("sin(3.14159265358979323/2.00000000000000000000000000)", 0.0, 1.0);
-        test("cos()", 0.0, 1.0);
+        test("cos()", 0.0, NOPOINT);
         test("cos(0.0)", 0.0, 1.0);
         test("cos(3.14159265358979323)", 0.0, -1.0);
@@ -125,5 +129,5 @@ int main() {
         test("cos(acos(x))", 0.3875823288, 0.3875823288, 0.0000000001);
         test("acos(cos(x))", 2.3875823288, 2.3875823288, 0.0000000001);
-        test("asin(sin(x))", 2.3875823288, 2.3875823288, 0.0000000001);
+        test("asin(sin(x))", 2.3875823288, 2.3875823288, 0.0000000001); // FAILS
         test("sin(asin(x))", 0.3875823288, 0.3875823288, 0.0000000001);
         test("tan(atan(x))", 2.3875823288, 2.3875823288, 0.0000000001);
@@ -140,4 +144,6 @@ int main() {
         test("cbrt(2)", 0.0, 1.2599210498948734);
 
+        // TODO: cosh, exp, log, ln, sinh, tanh
+
         // Expressions / Comparison
         test("0.0>0.0", 0.0, 0.0);
@@ -149,5 +155,5 @@ int main() {
         test("1.0!=0.0", 0.0, 1.0);
         test("sin(1.0)!=sin(0.0)", 0.0, 1.0);
-        test("sin()!=sin()", 0.0, 0.0);
+        test("sin()!=sin()", 0.0, 1.0);
         test("0.0==0.0", 0.0, 1.0);
         test("1.0>0.0", 0.0, 1.0);
@@ -185,8 +191,36 @@ int main() {
         test("1.0 != (1.0 == 1.0)", 0.0, 0.0);
         test("0.0 == (1.0 == 0.0)", 0.0, 1.0);
+        test("-1==1", 0.0, 0.0);
+        test("-1==-1", 0.0, 1.0);
+        test("1==-1", 0.0, 0.0);
+        test("1!=-1", 0.0, 1.0);
+        test("-1!=1", 0.0, 1.0);
+        test("-1!=-1", 0.0, 0.0);
+        test("!0.0", 0.0, 1.0);
+        test("!1.0", 0.0, 0.0);
+        test("!-1.0", 0.0, 0.0);
+        test("!2.0", 0.0, 0.0);
+        test("!x", INF, 0.0);
+        test("!x", NOPOINT, 1.0); // FAILS
+        test("!(1 > 2)", 0.0, 1.0);
+        test("!1.0 > -1.0", 0.0, 1.0);  // (!1.0) > -1.0
 
         // Bit operations
+        test("32&4", 0.0, 0.0);
+        test("32&4|2", 0.0, 2.0);
+        test("32|4&2", 0.0, 0.0);
+        test("32|4", 0.0, 36.0);
+        test("0&257", 0.0, 0.0);
+        test("257&0", 0.0, 0.0);
+        test("257|0", 0.0, 257.0);
+        test("0|257", 0.0, 257.0);
 
-        // Plugins
+        // Hmmm?
+        test("-1|257", 0.0, 257.0);  // What should be correct?
+        test("257|-1", 0.0, 257.0);  // What should be correct?
+
+        // TODO: Vectors, Scalars
+
+        // TODO: Plugins
 
         return 0;





More information about the Kst mailing list