|
| 1 | +import test from 'ava' ; |
| 2 | +import { ZZ , ZeroDivisionError } from '../../../src' ; |
| 3 | + |
| 4 | +function macro ( t , a , b , expected ) { |
| 5 | + t.is(expected, ZZ.from(a).divides(ZZ.from(b))) ; |
| 6 | +} |
| 7 | + |
| 8 | +macro.title = ( providedTitle , a , b , expected ) => expected ? `${a} divides ${b}` : `${a} does not divide ${b}` ; |
| 9 | + |
| 10 | +test( 'zero.divides(x) throws' , t => { t.throws( () => ZZ.$0().divides(ZZ.from(1)) , { instanceOf: ZeroDivisionError } )}) |
| 11 | + |
| 12 | +test( macro , 2 , 4 , true ) ; |
| 13 | +test( macro , 7 , 14 , true ) ; |
| 14 | +test( macro , 1 , '290843274237498327402783497239472937493274092479327' , true ) ; |
| 15 | +test( macro , -1 , '290843274237498327402783497239472937493274092479327' , true ) ; |
| 16 | +test( macro , 1 , '-290843274237498327402783497239472937493274092479327' , true ) ; |
| 17 | +test( macro , -1 , '-290843274237498327402783497239472937493274092479327' , true ) ; |
| 18 | + |
| 19 | +test( macro , 2 , 3 , false ) ; |
| 20 | +test( macro , 4 , 2 , false ) ; |
0 commit comments