]> www.ginac.de Git - ginac.git/blobdiff - check/exam_pseries.cpp
lexer: when switching to another output stream, clean last read character.
[ginac.git] / check / exam_pseries.cpp
index b0ccac3eba904839a21499b0fcbd39812fa7510e..a3fe7d87d496be2e0681c3e364f8a1cbe0af9ffe 100644 (file)
@@ -3,7 +3,7 @@
  *  Series expansion test (Laurent and Taylor series). */
 
 /*
- *  GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2008 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
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "exams.h"
+#include <iostream>
+#include "ginac.h"
+using namespace std;
+using namespace GiNaC;
 
 static symbol x("x");
 
@@ -348,13 +351,25 @@ static unsigned exam_series12()
        return result;
 }
 
+// Test of the patch of Stefan Weinzierl that prevents an infinite loop if
+// a factor in a product is a complicated way of writing zero.
+static unsigned exam_series13()
+{
+       unsigned result = 0;
+
+       ex e = (new mul(pow(2,x), (1/x*(-(1+x)/(1-x)) + (1+x)/x/(1-x)))
+              )->setflag(status_flags::evaluated);
+       ex d = Order(x);
+       result += check_series(e,0,d,1);
+
+       return result;
+}
 
 unsigned exam_pseries()
 {
        unsigned result = 0;
        
        cout << "examining series expansion" << flush;
-       clog << "----------series expansion:" << endl;
        
        result += exam_series1();  cout << '.' << flush;
        result += exam_series2();  cout << '.' << flush;
@@ -368,12 +383,12 @@ unsigned exam_pseries()
        result += exam_series10();  cout << '.' << flush;
        result += exam_series11();  cout << '.' << flush;
        result += exam_series12();  cout << '.' << flush;
+       result += exam_series13();  cout << '.' << flush;
        
-       if (!result) {
-               cout << " passed " << endl;
-               clog << "(no output)" << endl;
-       } else {
-               cout << " failed " << endl;
-       }
        return result;
 }
+
+int main(int argc, char** argv)
+{
+       return exam_pseries();
+}