]> gitweb.factorcode.org Git - factor.git/commitdiff
math.polynomials: add test for negative p^.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 6 Jan 2014 04:08:46 +0000 (20:08 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 6 Jan 2014 04:08:46 +0000 (20:08 -0800)
basis/math/polynomials/polynomials-tests.factor
basis/math/polynomials/polynomials.factor

index 43217b452c49b807b8c1ae34c9b32b2a4776b280..4ea6bb11e8dca4481df927451df03b06ab26b20b 100644 (file)
@@ -17,6 +17,7 @@ IN: math.polynomials.tests
 [ { 4 8 0 12 } ] [ 4 { 1 2 0 3 } n*p ] unit-test
 [ { 1 4 4 0 0 } ] [ { 1 2 0 } p-sq ] unit-test
 [ { 1 6 12 8 0 0 0 } ] [ { 1 2 0 } 3 p^ ] unit-test
+[ { 1 2 0 } -3 p^ ] [ negative-power-polynomial? ] must-fail-with
 [ { 1 } ] [ { 1 2 0 } 0 p^ ] unit-test
 [ { 1 4 7 6 0 0 0 0 0 } ] [ { 1 2 3 0 0 0 } { 1 2 0 0 } p* ] unit-test
 [ V{ 7 -2 1 } V{ -20 0 0 } ] [ { 1 1 1 1 } { 3 1 } p/mod ] unit-test
index 045b661602cb2d3b50929f944130095e309def5d..1212f630514a764915f35c119c375e109080c525 100644 (file)
@@ -46,9 +46,7 @@ ERROR: negative-power-polynomial p n ;
     make-bits { 1 } [ [ over p* ] when [ p-sq ] dip ] reduce nip ;
 
 : p^ ( p n -- p^n )
-    dup 0 >=
-    [ (p^) ]
-    [ negative-power-polynomial ] if ;
+    dup 0 >= [ (p^) ] [ negative-power-polynomial ] if ;
 
 <PRIVATE