math.polynomials: add test for negative p^.

db4
John Benediktsson 2014-01-05 20:08:46 -08:00
parent 351d68b1e1
commit 97b0ad7499
2 changed files with 2 additions and 3 deletions

View 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

View 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