001    package ps1.test;
002    
003    import ps1.*;
004    
005    import junit.framework.*;
006    
007    /**
008     * This class contains a set of test cases that can be used to test the
009     * implementation of the RatPoly class.
010     * <p>
011     */
012    public final class RatPolyTest extends TestCase {
013        // get a RatNum for an integer
014        private RatNum num(int i) {
015            return new RatNum(i);
016        }
017    
018        // convenient way to make a RatPoly
019        private RatPoly poly(int coef, int expt) {
020            return new RatPoly(coef, expt);
021        }
022    
023        // Convenient way to make a quadratic polynomial, arguments
024        // are just the coefficients, highest degree term to lowest
025        private RatPoly quadPoly(int x2, int x1, int x0) {
026            RatPoly ratPoly = new RatPoly(x2, 2);
027            return ratPoly.add(poly(x1, 1)).add(poly(x0, 0));
028        }
029    
030        // convenience for valueOf
031        private RatPoly valueOf(String s) {
032            return RatPoly.valueOf(s);
033        }
034    
035        // convenience for zero RatPoly
036        private RatPoly zero() {
037            return new RatPoly();
038        }
039    
040        public RatPolyTest(String name) {
041            super(name);
042        }
043    
044        // only toString is tested here
045        private void eq(RatPoly p, String target) {
046            String t = p.toString();
047            assertEquals(target, t);
048        }
049    
050        private void eq(RatPoly p, String target, String message) {
051            String t = p.toString();
052            assertEquals(message, target, t);
053        }
054    
055        // parses s into p, and then checks that it is as anticipated
056        // forall i, valueOf(s).coeff(anticipDegree - i) = anticipCoeffForExpts(i)
057        // (anticipDegree - i) means that we expect coeffs to be expressed
058        // corresponding to decreasing expts
059        private void eqP(String s, int anticipDegree, RatNum[] anticipCoeffs) {
060            RatPoly p = valueOf(s);
061            assertTrue(p.degree() == anticipDegree);
062            for (int i = 0; i <= anticipDegree; i++) {
063                assertTrue("wrong coeff; \n" + "anticipated: " + anticipCoeffs[i]
064                        + "; received: " + p.getTerm(anticipDegree - i).getCoeff()
065                        + "\n" + " received: " + p + " anticipated:" + s, p
066                        .getTerm(anticipDegree - i).getCoeff().equals(
067                                anticipCoeffs[i]));
068            }
069        }
070    
071        // added convenience: express coeffs as ints
072        private void eqP(String s, int anticipDegree, int[] intCoeffs) {
073            RatNum[] coeffs = new RatNum[intCoeffs.length];
074            for (int i = 0; i < coeffs.length; i++) {
075                coeffs[i] = num(intCoeffs[i]);
076            }
077            eqP(s, anticipDegree, coeffs);
078        }
079    
080        // make sure that unparsing a parsed string yields the string itself
081        private void assertToStringWorks(String s) {
082            assertEquals(s, valueOf(s).toString());
083        }
084    
085        public void testNoArgCtor() {
086            eq(new RatPoly(), "0");
087        }
088    
089        public void testTwoArgCtor() {
090            eq(poly(0, 0), "0");
091            eq(poly(0, 1), "0");
092            eq(poly(1, 0), "1");
093            eq(poly(-1, 0), "-1");
094            eq(poly(1, 1), "x");
095            eq(poly(1, 2), "x^2");
096            eq(poly(2, 2), "2*x^2");
097            eq(poly(2, 3), "2*x^3");
098            eq(poly(-2, 3), "-2*x^3");
099            eq(poly(-1, 1), "-x");
100            eq(poly(-1, 3), "-x^3");
101        }
102    
103        public void testIsNaN() {
104            assertTrue(RatPoly.valueOf("NaN").isNaN());
105            assertFalse(RatPoly.valueOf("1").isNaN());
106            assertFalse(RatPoly.valueOf("1/2").isNaN());
107            assertFalse(RatPoly.valueOf("x+1").isNaN());
108            assertFalse(RatPoly.valueOf("x^2+x+1").isNaN());
109            RatPoly empty = new RatPoly();
110            assertTrue(empty.div(empty).isNaN());
111        }
112    
113        public void testValueOfSimple() {
114            eqP("0", 0, new int[] { 0 });
115            eqP("x", 1, new int[] { 1, 0 });
116            eqP("x^2", 2, new int[] { 1, 0, 0 });
117        }
118    
119        public void testValueOfMultTerms() {
120            eqP("x^3+x^2", 3, new int[] { 1, 1, 0, 0 });
121            eqP("x^3-x^2", 3, new int[] { 1, -1, 0, 0 });
122            eqP("x^10+x^2", 10, new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 });
123        }
124    
125        public void testValueOfLeadingNeg() {
126            eqP("-x^2", 2, new int[] { -1, 0, 0 });
127            eqP("-x^2+1", 2, new int[] { -1, 0, 1 });
128            eqP("-x^2+x", 2, new int[] { -1, 1, 0 });
129        }
130    
131        public void testValueOfLeadingConstants() {
132            eqP("10*x", 1, new int[] { 10, 0 });
133    
134            eqP("10*x^4+x^2", 4, new int[] { 10, 0, 1, 0, 0 });
135    
136            eqP("10*x^4+100*x^2", 4, new int[] { 10, 0, 100, 0, 0 });
137    
138            eqP("-10*x^4+100*x^2", 4, new int[] { -10, 0, 100, 0, 0 });
139        }
140    
141        public void testValueOfRationals() {
142            eqP("1/2", 0, new RatNum[] { num(1).div(num(2)) });
143            eqP("1/2*x", 1, new RatNum[] { num(1).div(num(2)), num(0) });
144            eqP("x+1/3", 1, new RatNum[] { num(1), num(1).div(num(3)) });
145            eqP("1/2*x+1/3", 1, new RatNum[] { num(1).div(num(2)),
146                    num(1).div(num(3)) });
147            eqP("1/2*x+3/2", 1, new RatNum[] { num(1).div(num(2)),
148                    num(3).div(num(2)) });
149            eqP("1/2*x^3+3/2", 3, new RatNum[] { num(1).div(num(2)), num(0),
150                    num(0), num(3).div(num(2)) });
151            eqP("1/2*x^3+3/2*x^2+1", 3, new RatNum[] { num(1).div(num(2)),
152                    num(3).div(num(2)), num(0), num(1) });
153        }
154    
155        public void testValueOfNaN() {
156            assertTrue(valueOf("NaN").isNaN());
157        }
158    
159        public void testToStringSimple() {
160            assertToStringWorks("0");
161            assertToStringWorks("x");
162            assertToStringWorks("x^2");
163        }
164    
165        public void testToStringMultTerms() {
166            assertToStringWorks("x^3+x^2");
167            assertToStringWorks("x^3-x^2");
168            assertToStringWorks("x^100+x^2");
169        }
170    
171        public void testToStringLeadingNeg() {
172            assertToStringWorks("-x^2");
173            assertToStringWorks("-x^2+1");
174            assertToStringWorks("-x^2+x");
175        }
176    
177        public void testToStringLeadingConstants() {
178            assertToStringWorks("10*x");
179            assertToStringWorks("10*x^100+x^2");
180            assertToStringWorks("10*x^100+100*x^2");
181            assertToStringWorks("-10*x^100+100*x^2");
182        }
183    
184        public void testToStringRationals() {
185            assertToStringWorks("1/2");
186            assertToStringWorks("1/2*x");
187            assertToStringWorks("x+1/3");
188            assertToStringWorks("1/2*x+1/3");
189            assertToStringWorks("1/2*x+3/2");
190            assertToStringWorks("1/2*x^10+3/2");
191            assertToStringWorks("1/2*x^10+3/2*x^2+1");
192        }
193    
194        public void testToStringNaN() {
195            assertToStringWorks("NaN");
196        }
197    
198        public void testDegree() {
199            assertTrue("x^0 degree 0", poly(1, 0).degree() == 0);
200            assertTrue("x^1 degree 1", poly(1, 1).degree() == 1);
201            assertTrue("x^100 degree 100", poly(1, 100).degree() == 100);
202            assertTrue("0*x^100 degree 0", poly(0, 100).degree() == 0);
203            assertTrue("0*x^0 degree 0", poly(0, 0).degree() == 0);
204        }
205    
206        public void testAdd() {
207            RatPoly _XSqPlus2X = poly(1, 2).add(poly(1, 1)).add(poly(1, 1));
208            RatPoly _2XSqPlusX = poly(1, 2).add(poly(1, 2)).add(poly(1, 1));
209    
210            eq(poly(1, 0).add(poly(1, 0)), "2");
211            eq(poly(1, 0).add(poly(5, 0)), "6");
212            eq(poly(1, 0).add(poly(-1, 0)), "0");
213            eq(poly(1, 1).add(poly(1, 1)), "2*x");
214            eq(poly(1, 2).add(poly(1, 2)), "2*x^2");
215            eq(poly(1, 2).add(poly(1, 1)), "x^2+x");
216            eq(_XSqPlus2X, "x^2+2*x");
217            eq(_2XSqPlusX, "2*x^2+x");
218            eq(poly(1, 3).add(poly(1, 1)), "x^3+x");
219        }
220        
221        public void testNegate() {
222            eq(poly(0, 0).negate(), "0");
223            eq(poly(1,0).negate(), "-1");
224            eq(poly(-1,0).negate(), "1");
225            eq(poly(1,1).negate(), "-x");
226            eq(poly(-1,1).negate(), "x");
227            eq(poly(1, 2).add(poly(1, 1)).negate(), "-x^2-x");
228            eq(poly(-1, 2).sub(poly(1, 1)).negate(), "x^2+x");   
229        }
230    
231        public void testSub() {
232            eq(poly(1, 1).sub(poly(1, 0)), "x-1");
233            eq(poly(1, 1).add(poly(1, 0)), "x+1");
234            eq(poly(1, 0).sub(poly(1, 0)), "0");
235        }
236    
237        public void testMul() {
238            eq(poly(0, 0).mul(poly(0, 0)), "0");
239            eq(poly(1, 0).mul(poly(1, 0)), "1");
240            eq(poly(1, 0).mul(poly(2, 0)), "2");
241            eq(poly(2, 0).mul(poly(2, 0)), "4");
242            eq(poly(1, 0).mul(poly(1, 1)), "x");
243            eq(poly(1, 1).mul(poly(1, 1)), "x^2");
244            eq(poly(1, 1).sub(poly(1, 0)).mul(poly(1, 1).add(poly(1, 0))), "x^2-1");
245        }
246    
247        public void testOpsWithNaN(RatPoly p) {
248            RatPoly nan = RatPoly.valueOf("NaN");
249            eq(p.add(nan), "NaN");
250            eq(nan.add(p), "NaN");
251            eq(p.sub(nan), "NaN");
252            eq(nan.sub(p), "NaN");
253            eq(p.mul(nan), "NaN");
254            eq(nan.mul(p), "NaN");
255            eq(p.div(nan), "NaN");
256            eq(nan.div(p), "NaN");
257        }
258    
259        public void testOpsWithNaN() {
260            testOpsWithNaN(poly(0, 0));
261            testOpsWithNaN(poly(0, 1));
262            testOpsWithNaN(poly(1, 0));
263            testOpsWithNaN(poly(1, 1));
264            testOpsWithNaN(poly(2, 0));
265            testOpsWithNaN(poly(2, 1));
266            testOpsWithNaN(poly(0, 2));
267            testOpsWithNaN(poly(1, 2));
268        }
269    
270        public void testImmutabilityOfOperations() {
271            // not the most thorough test possible, but hopefully will
272            // catch the easy cases early on...
273            RatPoly one = poly(1, 0);
274            RatPoly two = poly(2, 0);
275            RatPoly empty = new RatPoly();
276    
277            one.degree();
278            two.degree();
279            eq(one, "1", "Degree mutates receiver!");
280            eq(two, "2", "Degree mutates receiver!");
281    
282            one.getTerm(0);
283            two.getTerm(0);
284            eq(one, "1", "Coeff mutates receiver!");
285            eq(two, "2", "Coeff mutates receiver!");
286    
287            one.isNaN();
288            two.isNaN();
289            eq(one, "1", "isNaN mutates receiver!");
290            eq(two, "2", "isNaN mutates receiver!");
291    
292            one.eval(0.0);
293            two.eval(0.0);
294            eq(one, "1", "eval mutates receiver!");
295            eq(two, "2", "eval mutates receiver!");
296    
297            one.negate();
298            two.negate();
299            eq(one, "1", "Negate mutates receiver!");
300            eq(two, "2", "Negate mutates receiver!");
301    
302            one.add(two);
303            eq(one, "1", "Add mutates receiver!");
304            eq(two, "2", "Add mutates argument!");
305    
306            one.sub(two);
307            eq(one, "1", "Sub mutates receiver!");
308            eq(two, "2", "Sub mutates argument!");
309    
310            one.mul(two);
311            eq(one, "1", "Mul mutates receiver!");
312            eq(two, "2", "Mul mutates argument!");
313    
314            one.div(two);
315            eq(one, "1", "Div mutates receiver!");
316            eq(two, "2", "Div mutates argument!");
317    
318            empty.div(new RatPoly());
319            assertFalse("Div Mutates reciever", empty.isNaN());
320        }
321    
322        public void testEval() {
323            RatPoly zero = new RatPoly();
324            RatPoly one = new RatPoly(1, 0);
325            RatPoly _X = new RatPoly(1, 1);
326            RatPoly _2X = new RatPoly(2, 1);
327            RatPoly _XSq = new RatPoly(1, 2);
328    
329            assertEquals(" 0 at 0 ", 0.0, zero.eval(0.0), 0.0001);
330            assertEquals(" 0 at 1 ", 0.0, zero.eval(1.0), 0.0001);
331            assertEquals(" 0 at 2 ", 0.0, zero.eval(2.0), 0.0001);
332            assertEquals(" 1 at 0 ", 1.0, one.eval(0.0), 0.0001);
333            assertEquals(" 1 at 1 ", 1.0, one.eval(1.0), 0.0001);
334            assertEquals(" 1 at 1 ", 1.0, one.eval(2.0), 0.0001);
335    
336            assertEquals(" x at 0 ", 0.0, _X.eval(0.0), 0.0001);
337            assertEquals(" x at 1 ", 1.0, _X.eval(1.0), 0.0001);
338            assertEquals(" x at 2 ", 2.0, _X.eval(2.0), 0.0001);
339    
340            assertEquals(" 2*x at 0 ", 0.0, _2X.eval(0.0), 0.0001);
341            assertEquals(" 2*x at 1 ", 2.0, _2X.eval(1.0), 0.0001);
342            assertEquals(" 2*x at 2 ", 4.0, _2X.eval(2.0), 0.0001);
343    
344            assertEquals(" x^2 at 0 ", 0.0, _XSq.eval(0.0), 0.0001);
345            assertEquals(" x^2 at 1 ", 1.0, _XSq.eval(1.0), 0.0001);
346            assertEquals(" x^2 at 2 ", 4.0, _XSq.eval(2.0), 0.0001);
347    
348            RatPoly _XSq_minus_2X = _XSq.sub(_2X);
349    
350            assertEquals(" x^2-2*x at 0 ", 0.0, _XSq_minus_2X.eval(0.0), 0.0001);
351            assertEquals(" x^2-2*x at 1 ", -1.0, _XSq_minus_2X.eval(1.0), 0.0001);
352            assertEquals(" x^2-2*x at 2 ", 0.0, _XSq_minus_2X.eval(2.0), 0.0001);
353            assertEquals(" x^2-2*x at 3 ", 3.0, _XSq_minus_2X.eval(3.0), 0.0001);
354        }
355    
356        public void testGetTerm() {
357            // getTerm already gets some grunt testing in eqP; checking an
358            // interesting
359            // input here...
360            RatPoly _XSqPlus2X = poly(1, 2).add(poly(1, 1)).add(poly(1, 1));
361            RatPoly _2XSqPlusX = poly(1, 2).add(poly(1, 2)).add(poly(1, 1));
362    
363            assertEquals(RatTerm.ZERO, _XSqPlus2X.getTerm(-1));
364            assertEquals(RatTerm.ZERO, _XSqPlus2X.getTerm(-10));
365            assertEquals(RatTerm.ZERO, _2XSqPlusX.getTerm(-1));
366            assertEquals(RatTerm.ZERO, _2XSqPlusX.getTerm(-10));
367            assertEquals(RatTerm.ZERO, zero().getTerm(-10));
368            assertEquals(RatTerm.ZERO, zero().getTerm(-1));
369        }
370    
371        public void testDiv() {
372            // 0/x = 0
373            eq(poly(0, 1).div(poly(1, 1)), "0");
374    
375            // 2/1 = 2
376            eq(poly(2, 0).div(poly(1, 0)), "2");
377    
378            // x/x = 1
379            eq(poly(1, 1).div(poly(1, 1)), "1");
380    
381            // -x/x = -1
382            eq(poly(-1, 1).div(poly(1, 1)), "-1");
383    
384            // x/-x = -1
385            eq(poly(1, 1).div(poly(-1, 1)), "-1");
386    
387            // -x/-x = 1
388            eq(poly(-1, 1).div(poly(-1, 1)), "1");
389    
390            // -x^2/x = -x
391            eq(poly(-1, 2).div(poly(1, 1)), "-x");
392    
393            // x^100/x^1000 = 0
394            eq(poly(1, 100).div(poly(1, 1000)), "0");
395    
396            // x^100/x = x^99
397            eq(poly(1, 100).div(poly(1, 1)), "x^99");
398    
399            // x^99/x^98 = x
400            eq(poly(1, 99).div(poly(1, 98)), "x");
401    
402            // x^10 / x = x^9 (r: 0)
403            eq(poly(1, 10).div(poly(1, 1)), "x^9");
404    
405            // x^10 / x^3+x^2 = x^7-x^6+x^5-x^4+x^3-x^2+x-1 (r: -x^2)
406            eq(poly(1, 10).div(poly(1, 3).add(poly(1, 2))),
407                    "x^7-x^6+x^5-x^4+x^3-x^2+x-1");
408    
409            // x^10 / x^3+x^2+x = x^7-x^6+x^4-x^3+x-1 (r: -x)
410            eq(poly(1, 10).div(poly(1, 3).add(poly(1, 2).add(poly(1, 1)))),
411                    "x^7-x^6+x^4-x^3+x-1");
412    
413            // x^10+x^5 / x = x^9+x^4 (r: 0)
414            eq(poly(1, 10).add(poly(1, 5)).div(poly(1, 1)), "x^9+x^4");
415    
416            // x^10+x^5 / x^3 = x^7+x^2 (r: 0)
417            eq(poly(1, 10).add(poly(1, 5)).div(poly(1, 3)), "x^7+x^2");
418    
419            // x^10+x^5 / x^3+x+3 = x^7-x^5-3*x^4+x^3+7*x^2+8*x-10 (r:
420            // 29*x^2+14*x-30)
421            eq(poly(1, 10).add(poly(1, 5)).div(
422                    poly(1, 3).add(poly(1, 1)).add(poly(3, 0))),
423                    "x^7-x^5-3*x^4+x^3+7*x^2+8*x-10");
424        }
425    
426        public void testDivComplexI() {
427            // (x+1)*(x+1) = x^2+2*x+1
428            eq(poly(1, 2).add(poly(2, 1)).add(poly(1, 0)).div(
429                    poly(1, 1).add(poly(1, 0))), "x+1");
430    
431            // (x-1)*(x+1) = x^2-1
432            eq(poly(1, 2).add(poly(-1, 0)).div(poly(1, 1).add(poly(1, 0))), "x-1");
433        }
434    
435        public void testDivComplexII() {
436            // x^8+2*x^6+8*x^5+2*x^4+17*x^3+11*x^2+8*x+3 =
437            // (x^3+2*x+1) * (x^5+7*x^2+2*x+3)
438            RatPoly large = poly(1, 8).add(poly(2, 6)).add(poly(8, 5)).add(
439                    poly(2, 4)).add(poly(17, 3)).add(poly(11, 2)).add(poly(8, 1))
440                    .add(poly(3, 0));
441    
442            // x^3+2*x+1
443            RatPoly sub1 = poly(1, 3).add(poly(2, 1)).add(poly(1, 0));
444            // x^5+7*x^2+2*x+3
445            RatPoly sub2 = poly(1, 5).add(poly(7, 2)).add(poly(2, 1)).add(
446                    poly(3, 0));
447    
448            // just a last minute typo check...
449            eq(sub1.mul(sub2), large.toString());
450            eq(sub2.mul(sub1), large.toString());
451    
452            eq(large.div(sub2), "x^3+2*x+1");
453            eq(large.div(sub1), "x^5+7*x^2+2*x+3");
454        }
455    
456        public void testDivExamplesFromSpec() {
457            // seperated this test case out because it has a dependency on
458            // both "valueOf" and "div" functioning properly
459    
460            // example 1 from spec
461            eq(valueOf("x^3-2*x+3").div(valueOf("3*x^2")), "1/3*x");
462            // example 2 from spec
463            eq(valueOf("x^2+2*x+15").div(valueOf("2*x^3")), "0");
464        }
465    
466        public void testDivExampleFromPset() {
467            eq(valueOf("x^8+x^6+10*x^4+10*x^3+8*x^2+2*x+8").div(
468                    valueOf("3*x^6+5*x^4+9*x^2+4*x+8")), "1/3*x^2-2/9");
469        }
470    
471        private void assertIsNaNanswer(RatPoly nanAnswer) {
472            eq(nanAnswer, "NaN");
473        }
474    
475        public void testDivByZero() {
476            RatPoly nanAnswer;
477            nanAnswer = poly(1, 0).div(zero());
478            assertIsNaNanswer(nanAnswer);
479    
480            nanAnswer = poly(1, 1).div(zero());
481            assertIsNaNanswer(nanAnswer);
482        }
483    
484        public void testDivByPolyWithNaN() {
485            RatPoly nan_x2 = poly(1, 2).mul(poly(1, 1).div(zero()));
486            RatPoly one_x1 = new RatPoly(1, 1);
487    
488            assertIsNaNanswer(nan_x2.div(one_x1));
489            assertIsNaNanswer(one_x1.div(nan_x2));
490            assertIsNaNanswer(nan_x2.div(zero()));
491            assertIsNaNanswer(zero().div(nan_x2));
492            assertIsNaNanswer(nan_x2.div(nan_x2));
493        }
494    
495        public void testDifferentiate() {
496            eq(poly(1, 1).differentiate(), "1");
497            eq(quadPoly(7, 5, 99).differentiate(), "14*x+5");
498            eq(quadPoly(3, 2, 1).differentiate(), "6*x+2");
499            eq(quadPoly(1, 0, 1).differentiate(), "2*x");
500            assertIsNaNanswer(RatPoly.valueOf("NaN").differentiate());
501        }
502    
503        public void testAntiDifferentiate() {
504            eq(poly(1, 0).antiDifferentiate(new RatNum(1)), "x+1");
505            eq(poly(2, 1).antiDifferentiate(new RatNum(1)), "x^2+1");
506            eq(quadPoly(0, 6, 2).antiDifferentiate(new RatNum(1)), "3*x^2+2*x+1");
507            eq(quadPoly(4, 6, 2).antiDifferentiate(new RatNum(0)),
508                    "4/3*x^3+3*x^2+2*x");
509    
510            assertIsNaNanswer(RatPoly.valueOf("NaN").antiDifferentiate(
511                    new RatNum(1)));
512            assertIsNaNanswer(poly(1, 0).antiDifferentiate(new RatNum(1, 0)));
513        }
514    
515        public void testIntegrate() {
516            assertEquals("one from 0 to 1", 1.0, poly(1, 0).integrate(0, 1), 0.0001);
517            assertEquals("2x from 1 to -2", 3.0, poly(2, 1).integrate(1, -2),
518                    0.0001);
519            assertEquals("7*x^2+6*x+2 from 1 to 5", 369.33333333, quadPoly(7, 6, 2)
520                    .integrate(1, 5), 0.0001);
521            assertEquals("NaN", RatPoly.valueOf("NaN").integrate(0, 1), Double.NaN);
522        }
523        
524    
525        // Tell JUnit what order to run the tests in
526        public static Test suite() {
527            TestSuite suite = new TestSuite();
528            suite.addTest(new RatPolyTest("testValueOfSimple"));
529            suite.addTest(new RatPolyTest("testValueOfMultTerms"));
530            suite.addTest(new RatPolyTest("testValueOfLeadingNeg"));
531            suite.addTest(new RatPolyTest("testValueOfLeadingConstants"));
532            suite.addTest(new RatPolyTest("testValueOfRationals"));
533            suite.addTest(new RatPolyTest("testValueOfNaN"));
534            suite.addTest(new RatPolyTest("testToStringSimple"));
535            suite.addTest(new RatPolyTest("testToStringMultTerms"));
536            suite.addTest(new RatPolyTest("testToStringLeadingNeg"));
537            suite.addTest(new RatPolyTest("testToStringLeadingConstants"));
538            suite.addTest(new RatPolyTest("testToStringRationals"));
539            suite.addTest(new RatPolyTest("testToStringNaN"));
540            suite.addTest(new RatPolyTest("testNoArgCtor"));
541            suite.addTest(new RatPolyTest("testTwoArgCtor"));
542            suite.addTest(new RatPolyTest("testDegree"));
543            suite.addTest(new RatPolyTest("testAdd"));
544            suite.addTest(new RatPolyTest("testNegate"));
545            suite.addTest(new RatPolyTest("testSub"));
546            suite.addTest(new RatPolyTest("testMul"));
547            suite.addTest(new RatPolyTest("testOpsWithNaN"));
548            suite.addTest(new RatPolyTest("testDiv"));
549            suite.addTest(new RatPolyTest("testDivComplexI"));
550            suite.addTest(new RatPolyTest("testDivComplexII"));
551            suite.addTest(new RatPolyTest("testDivExamplesFromSpec"));
552            suite.addTest(new RatPolyTest("testDivExampleFromPset"));
553            suite.addTest(new RatPolyTest("testDivByZero"));
554            suite.addTest(new RatPolyTest("testDivByPolyWithNaN"));
555            suite.addTest(new RatPolyTest("testIsNaN"));
556            suite.addTest(new RatPolyTest("testEval"));
557            suite.addTest(new RatPolyTest("testImmutabilityOfOperations"));
558            suite.addTest(new RatPolyTest("testDifferentiate"));
559            suite.addTest(new RatPolyTest("testAntiDifferentiate"));
560            suite.addTest(new RatPolyTest("testIntegrate"));
561            return suite;
562        }
563    }