Skip to content

Commit 919f19e

Browse files
committed
more coverage
1 parent 5c11dfb commit 919f19e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/polyform.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,15 @@ quick_cancel(x) = x
311311
quick_cancel(x, y) = isequal(x, y) ? (1,1) : (x, y)
312312

313313
function quick_cancel(x::Pow, y)
314+
x.exp isa Number || return (x, y)
314315
isequal(x.base, y) && x.exp >= 1 ? (Pow{symtype(x)}(x.base, x.exp - 1),1) : (x, y)
315316
end
316317

317318
quick_cancel(y, x::Pow) = reverse(quick_cancel(x,y))
318319

319320
function quick_cancel(x::Pow, y::Pow)
320321
if isequal(x.base, y.base)
322+
!(x.exp isa Number && y.exp isa Number) && return (x, y)
321323
if x.exp > y.exp
322324
return Pow{symtype(x)}(x.base, x.exp-y.exp), 1
323325
elseif x.exp == y.exp
@@ -347,6 +349,7 @@ function quick_cancel(x::Mul, y)
347349
end
348350

349351
function quick_cancel(x::Mul, y::Pow)
352+
y.exp isa Number || return (x, y)
350353
if haskey(x.dict, y.base)
351354
d = copy(x.dict)
352355
if x.dict[y.base] > y.exp

test/polyform.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@ end
4545
@eqtest simplify_fractions(2x / (3(x^3)*y)) == simplify_fractions(2/(3*(y*x^2)))
4646
@eqtest simplify_fractions(x^2 / (3(x^3)*y)) == simplify_fractions(1/(3*(y*x)))
4747
@eqtest simplify_fractions((3(x^3)*y) / x^2) == simplify_fractions(3*(y*x))
48+
@eqtest simplify_fractions(x^2/x^4) == (1/x^2)
49+
@eqtest simplify_fractions(x^2/x^3) == 1/x
50+
@eqtest simplify_fractions(x^3/x^2) == x
51+
@eqtest simplify_fractions(x^2/x^2) == 1
52+
@eqtest simplify_fractions(3x^2/x^3) == 3/x
53+
@eqtest simplify_fractions(3*(x^2)*(y^3)/(3*(x^3)*(y^2))) == y/x
54+
@eqtest simplify_fractions(3*(x^x)/x*y) == 3*(x^x)/x*y
4855
end

0 commit comments

Comments
 (0)