]> www.ginac.de Git - ginac.git/blobdiff - check/exam_paranoia.cpp
- collect_common_factors() works better with negative powers
[ginac.git] / check / exam_paranoia.cpp
index 9177cddb8a54fb22507097c2758c88775d363dcf..68762e963621f543da2afb3b5a50cbe0cc7046eb 100644 (file)
@@ -6,7 +6,7 @@
  *  these oopses for good, so we run those stupid tests... */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -352,6 +352,24 @@ static unsigned exam_paranoia14(void)
        return result;
 }
 
+// Under certain conditions, power::expand_add_2() could produce non-canonical
+// numeric expairs. Fixed on Oct 24, 2002.
+static unsigned exam_paranoia15(void)
+{
+       unsigned result = 0;
+
+       ex q = (pow(pow(2, numeric(1, 2))*2+1, 2)).expand();
+       // this used to produce "1+4*sqrt(2)+4*2" which would never evaluate
+       // to "9+4*sqrt(2)"
+
+       if (!(q-9-4*pow(2, numeric(1, 2))).is_zero()) {
+               clog << "expand((sqrt(2)*2+1)^2) erroneously returned " << q << " instead of 9-4*sqrt(2)\n";
+               ++result;
+       }
+
+       return result;
+}
+
 unsigned exam_paranoia(void)
 {
        unsigned result = 0;
@@ -373,6 +391,7 @@ unsigned exam_paranoia(void)
        result += exam_paranoia12();  cout << '.' << flush;
        result += exam_paranoia13();  cout << '.' << flush;
        result += exam_paranoia14();  cout << '.' << flush;
+       result += exam_paranoia15();  cout << '.' << flush;
        
        if (!result) {
                cout << " passed " << endl;