]> www.ginac.de Git - ginac.git/commitdiff
Add more ex::is_polynomial() tests
authorAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Sun, 7 Sep 2014 18:56:02 +0000 (22:56 +0400)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Sun, 7 Sep 2014 19:07:37 +0000 (23:07 +0400)
Improves commit 92da4c16 ('[bugfix] ex::is_polynomial(x): fix miscomputations')
a little bit.

check/exam_paranoia.cpp

index 2817d18e6c14aa8ce6b3a803f2c92e0717088571..d5f65f8e5e644e94319f78349d512f01f5c74b33 100644 (file)
@@ -522,6 +522,28 @@ static unsigned exam_paranoia20()
        return result;
 }
 
+static unsigned is_polynomial_false_positive()
+{
+       unsigned result = 0;
+       symbol x("x"), n("n");
+       exvector nonpoly_exprs;
+       nonpoly_exprs.push_back(1/(1-x));
+       nonpoly_exprs.push_back(1/(x+1));
+       nonpoly_exprs.push_back(-1/(x-1));
+       nonpoly_exprs.push_back(1/(1-x*x));
+       nonpoly_exprs.push_back(1/(1-pow(x,n)));
+       nonpoly_exprs.push_back(x-1/(x-1));
+       for (exvector::const_iterator ep = nonpoly_exprs.begin();
+            ep != nonpoly_exprs.end(); ++ep) {
+               if (ep->is_polynomial(x)) {
+                       clog << "(" << *ep << ").is_polynomial(" << x << ") "
+                               "erroneously returned true" << endl;
+                       ++result;
+               }
+       }
+       return result;
+}
+
 unsigned exam_paranoia()
 {
        unsigned result = 0;
@@ -548,6 +570,7 @@ unsigned exam_paranoia()
        result += exam_paranoia18();  cout << '.' << flush;
        result += exam_paranoia19();  cout << '.' << flush;
        result += exam_paranoia20();  cout << '.' << flush;
+       result += is_polynomial_false_positive(); cout << '.' << flush;
        
        return result;
 }