]> www.ginac.de Git - ginac.git/blobdiff - check/paranoia_check.cpp
- beautyfied names :-)
[ginac.git] / check / paranoia_check.cpp
index b7552dcdf8508fd7707f5710670f5367cc77889b..a47f1c23137636c6517009f66c9dd480a56df575 100644 (file)
@@ -85,7 +85,8 @@ static unsigned paranoia_check2(void)
              << g.eval() << endl;
         ++result;
     }
-    // This actually worked already back in April 1999.  But we are very paranoic!
+    // This actually worked already back in April 1999.
+    // But we are *very* paranoic!
     if (!g.expand().eval().is_zero()) {
         clog << "e = (x + z*x); f = e*y; eval(expand(f - e*y)) erroneously returned "
              << g.expand().eval() << endl;
@@ -215,12 +216,16 @@ static unsigned paranoia_check8(void)
     symbol x("x");
 
     ex e = -x / (x+1);
-    ex f = e.normal();
-
-    // The bug caused a division by zero in normal(), so the following
-    // check is actually bogus...
-    if (!f.is_equal(e)) {
-        clog << "normal(-x/(x+1)) returns " << f << " instead of -x/(x+1)\n";
+    ex f;
+    
+    try {
+        f = e.normal();
+        if (!f.is_equal(e)) {
+            clog << "normal(-x/(x+1)) returns " << f << " instead of -x/(x+1)\n";
+            ++result;
+        }
+    } catch (const exception &e) {
+        clog << "normal(-x/(x+1) throws " << e.what() << endl;
         ++result;
     }
     return result;
@@ -229,7 +234,7 @@ static unsigned paranoia_check8(void)
 // This one was a result of a modification to frac_cancel() & Co. to avoid
 // expanding the numerator and denominator when bringing them from Q[X] to
 // Z[X]. multiply_lcm() forgot to multiply the x-linear term with the LCM of
-// the coefficient's denominators (2 in this case). Introduced on Jan 25th
+// the coefficient's denominators (2 in this case).  Introduced on Jan 25th
 // 2000 and fixed on Jan 31th.
 static unsigned paranoia_check9(void)
 {
@@ -246,6 +251,31 @@ static unsigned paranoia_check9(void)
     return result;
 }
 
+// I have no idea when this broke.  It has been working long ago, before 0.4.0
+// and on Feb 13th 2000 I found out that things like 2^(3/2) throw an exception
+// "power::eval(): pow(0,0) is undefined" instead of simplifying to 2*2^(1/2).
+// It was fixed that same day.
+static unsigned paranoia_check10(void)
+{
+    unsigned result = 0;
+    
+    ex b = numeric(2);
+    ex e = numeric(3,2);
+    ex r;
+    
+    try {
+        r = pow(b,e).eval();
+        if (!(r-2*sqrt(ex(2))).is_zero()) {
+            clog << "2^(3/2) erroneously returned " << r << " instead of 2*sqrt(2)" << endl;
+            ++result;
+        }
+    } catch (const exception &e) {
+        clog << "2^(3/2) throws " << e.what() << endl;
+        ++result;
+    }
+    return result;
+}
+
 unsigned paranoia_check(void)
 {
     unsigned result = 0;
@@ -262,6 +292,7 @@ unsigned paranoia_check(void)
     result += paranoia_check7();
     result += paranoia_check8();
     result += paranoia_check9();
+    result += paranoia_check10();
 
     if (!result) {
         cout << " passed ";