From 708491c9e2df3690d58f1d93e4bd0506baeac103 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Sun, 7 Sep 2014 22:56:02 +0400 Subject: [PATCH] Add more ex::is_polynomial() tests Improves commit 92da4c16 ('[bugfix] ex::is_polynomial(x): fix miscomputations') a little bit. --- check/exam_paranoia.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/check/exam_paranoia.cpp b/check/exam_paranoia.cpp index 2817d18e..d5f65f8e 100644 --- a/check/exam_paranoia.cpp +++ b/check/exam_paranoia.cpp @@ -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; } -- 2.44.0