Skip to content

Commit d667095

Browse files
🔍 test: Test Integer.divides().
1 parent 66a8afe commit d667095

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/src/Integer/divides.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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

Comments
 (0)