Skip to content

Commit f29a0fc

Browse files
committed
Add trivial gcd tests
1 parent 3881822 commit f29a0fc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/flint/test/test_all.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,28 +3375,26 @@ def factor_sqf(p):
33753375
assert S(0).sqrt() == S(0)
33763376
assert S(1).sqrt() == S(1)
33773377
assert S(4).sqrt()**2 == S(4)
3378-
for i in range(100):
3378+
3379+
for i in range(-100, 100):
33793380
try:
33803381
assert S(i).sqrt() ** 2 == S(i)
33813382
except DomainError:
33823383
pass
33833384

33843385
if characteristic == 0:
33853386
assert raises(lambda: S(-1).sqrt(), DomainError)
3386-
else:
3387-
try:
3388-
assert S(-1).sqrt() ** 2 == S(-1)
3389-
except DomainError:
3390-
pass
33913387

33923388
assert (0*x).sqrt() == 0*x
33933389
assert (1*x/x).sqrt() == 0*x + 1
33943390
assert (4*x/x).sqrt()**2 == 0*x + 4
3395-
for i in range(100):
3391+
3392+
for i in range(-100, 100):
33963393
try:
33973394
assert (i*x).sqrt() ** 2 == i*x
33983395
except DomainError:
33993396
pass
3397+
34003398
assert (x**2).sqrt() == x
34013399
assert (S(4)*x**2).sqrt()**2 == S(4)*x**2
34023400
assert raises(lambda: (x**2 + 1).sqrt(), DomainError)
@@ -3416,6 +3414,14 @@ def factor_sqf(p):
34163414
assert factor_sqf(x**2) == (S(1), [(x, 2)])
34173415
assert factor_sqf(2*(x+1)) == (S(2), [(x+1, 1)])
34183416

3417+
assert (0*x).gcd(0*x) == 0*x
3418+
assert (0*x).gcd(0*x + 1) == S(1)
3419+
3420+
if not is_field:
3421+
assert (0*x).gcd(0*x + 3) == S(3)
3422+
else:
3423+
assert (0*x).gcd(0*x + 3) == S(1)
3424+
34193425
assert (2*x).gcd(x) == x
34203426
assert (2*x).gcd(x**2) == x
34213427
assert (2*x).gcd(x**2 + 1) == S(1)

0 commit comments

Comments
 (0)