]> www.ginac.de Git - ginac.git/blobdiff - check/exam_paranoia.cpp
Fix pow(+(...),2).expand().
[ginac.git] / check / exam_paranoia.cpp
index 4208e25c129bdbf9bea00bb39d5fe9c836325a1d..51bd3a55ee1baaa61d54a0f166f876d47f61dab6 100644 (file)
@@ -6,7 +6,7 @@
  *  these oopses for good, so we run those stupid tests... */
 
 /*
- *  GiNaC Copyright (C) 1999-2014 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2015 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
@@ -544,6 +544,18 @@ static unsigned is_polynomial_false_positive()
        return result;
 }
 
+// Bug in power::expand reported by Isuru Fernando (fixed 2015-05-07).
+static unsigned exam_paranoia21()
+{
+       symbol x("x");
+       ex e = pow(x + sqrt(ex(2))*x, 2).expand();
+       if (e.nops() != 2) {
+               clog << "(x+sqrt(2)*x)^2 was wrongly expanded to " << e << "\n";
+               return 1;
+       }
+       return 0;
+}
+
 unsigned exam_paranoia()
 {
        unsigned result = 0;
@@ -571,6 +583,7 @@ unsigned exam_paranoia()
        result += exam_paranoia19();  cout << '.' << flush;
        result += exam_paranoia20();  cout << '.' << flush;
        result += is_polynomial_false_positive(); cout << '.' << flush;
+       result += exam_paranoia21();  cout << '.' << flush;
        
        return result;
 }