Skip to content

Commit a29d142

Browse files
🔍 test: Better titles for generated tests.
1 parent 731a322 commit a29d142

29 files changed

+90
-32
lines changed

test/generate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def write ( f , left, right , name , t , ispow = False , isn = False , isi = Fal
7575
f.write("import test from 'ava' ;\n")
7676
f.write("import {{ parse , stringify , {} }} from '../../../../src' ;\n\n".format(name))
7777

78+
f.write("const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);\n\n")
79+
7880
if outputsize == 2 :
7981

8082
if isn :
@@ -124,20 +126,20 @@ def write ( f , left, right , name , t , ispow = False , isn = False , isi = Fal
124126

125127
if outputsize == 2 :
126128

127-
f.write("macro.title = ( _ , A , B , C , D ) => `{}(${{A}},${{B}}) = [${{C}},${{D}}]` ;\n\n".format(name))
128-
129129
if isn:
130+
f.write("macro.title = ( _ , A , B , C , D ) => `{}(${{fmt(A)}},${{B}}) = [${{fmt(C)}},${{fmt(D)}}]` ;\n\n".format(name))
130131
LINE = "test( macro , '{}' , {} , '{}' , '{}' ) ;\n"
131132
else:
133+
f.write("macro.title = ( _ , A , B , C , D ) => `{}(${{fmt(A)}},${{fmt(B)}}) = [${{fmt(C)}},${{fmt(D)}}]` ;\n\n".format(name))
132134
LINE = "test( macro , '{}' , '{}' , '{}' , '{}' ) ;\n"
133135

134136
else:
135137

136-
f.write("macro.title = ( _ , A , B , C ) => `{}(${{A}},${{B}}) = ${{C}}` ;\n\n".format(name))
137-
138138
if isn:
139+
f.write("macro.title = ( _ , A , B , C ) => `{}(${{fmt(A)}},${{B}}) = ${{fmt(C)}}` ;\n\n".format(name))
139140
LINE = "test( macro , '{}' , {} , '{}' ) ;\n"
140141
else:
142+
f.write("macro.title = ( _ , A , B , C ) => `{}(${{fmt(A)}},${{fmt(B)}}) = ${{fmt(C)}}` ;\n\n".format(name))
141143
LINE = "test( macro , '{}' , '{}' , '{}' ) ;\n"
142144

143145
for a in left :

test/src/integer/arithmetic/add.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , add } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `add(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `add(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '0' , '0' ) ;
1618
test( macro , '0' , '1' , '1' ) ;

test/src/integer/arithmetic/addn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , addn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = addn( a , B ) ;
79
t.is( stringify( a ) , A ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `addn(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `addn(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 0 , '0' ) ;
1416
test( macro , '0' , 1 , '1' ) ;

test/src/integer/arithmetic/div.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , div } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `div(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `div(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '1' , '0' ) ;
1618
test( macro , '0' , '-1' , '0' ) ;

test/src/integer/arithmetic/divmod.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , divmod } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C , D ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -11,7 +13,7 @@ function macro ( t , A , B , C , D ) {
1113
t.is( stringify( d ) , D ) ;
1214
}
1315

14-
macro.title = ( _ , A , B , C , D ) => `divmod(${A},${B}) = [${C},${D}]` ;
16+
macro.title = ( _ , A , B , C , D ) => `divmod(${fmt(A)},${fmt(B)}) = [${fmt(C)},${fmt(D)}]` ;
1517

1618
test( macro , '0' , '1' , '0' , '0' ) ;
1719
test( macro , '0' , '-1' , '0' , '0' ) ;

test/src/integer/arithmetic/divmodn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , divmodn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C , D ) {
57
const a = parse( A ) ;
68
const [c, d] = divmodn( a , B ) ;
@@ -9,7 +11,7 @@ function macro ( t , A , B , C , D ) {
911
t.is( stringify( d ) , D ) ;
1012
}
1113

12-
macro.title = ( _ , A , B , C , D ) => `divmodn(${A},${B}) = [${C},${D}]` ;
14+
macro.title = ( _ , A , B , C , D ) => `divmodn(${fmt(A)},${B}) = [${fmt(C)},${fmt(D)}]` ;
1315

1416
test( macro , '0' , 1 , '0' , '0' ) ;
1517
test( macro , '0' , -1 , '0' , '0' ) ;

test/src/integer/arithmetic/divn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , divn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = divn( a , B ) ;
79
t.is( stringify( a ) , A ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `divn(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `divn(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 1 , '0' ) ;
1416
test( macro , '0' , -1 , '0' ) ;

test/src/integer/arithmetic/iadd.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , iadd } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `iadd(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `iadd(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '0' , '0' ) ;
1618
test( macro , '0' , '1' , '1' ) ;

test/src/integer/arithmetic/iaddn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , iaddn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = iaddn( a , B ) ;
79
t.is( stringify( a ) , C ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `iaddn(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `iaddn(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 0 , '0' ) ;
1416
test( macro , '0' , 1 , '1' ) ;

test/src/integer/arithmetic/idiv.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , idiv } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `idiv(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `idiv(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '1' , '0' ) ;
1618
test( macro , '0' , '-1' , '0' ) ;

test/src/integer/arithmetic/idivmod.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , idivmod } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C , D ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -11,7 +13,7 @@ function macro ( t , A , B , C , D ) {
1113
t.is( stringify( d ) , D ) ;
1214
}
1315

14-
macro.title = ( _ , A , B , C , D ) => `idivmod(${A},${B}) = [${C},${D}]` ;
16+
macro.title = ( _ , A , B , C , D ) => `idivmod(${fmt(A)},${fmt(B)}) = [${fmt(C)},${fmt(D)}]` ;
1517

1618
test( macro , '0' , '1' , '0' , '0' ) ;
1719
test( macro , '0' , '-1' , '0' , '0' ) ;

test/src/integer/arithmetic/idivmodn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , idivmodn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C , D ) {
57
const a = parse( A ) ;
68
const [c, d] = idivmodn( a , B ) ;
@@ -9,7 +11,7 @@ function macro ( t , A , B , C , D ) {
911
t.is( stringify( d ) , D ) ;
1012
}
1113

12-
macro.title = ( _ , A , B , C , D ) => `idivmodn(${A},${B}) = [${C},${D}]` ;
14+
macro.title = ( _ , A , B , C , D ) => `idivmodn(${fmt(A)},${B}) = [${fmt(C)},${fmt(D)}]` ;
1315

1416
test( macro , '0' , 1 , '0' , '0' ) ;
1517
test( macro , '0' , -1 , '0' , '0' ) ;

test/src/integer/arithmetic/idivn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , idivn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = idivn( a , B ) ;
79
t.is( stringify( a ) , C ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `idivn(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `idivn(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 1 , '0' ) ;
1416
test( macro , '0' , -1 , '0' ) ;

test/src/integer/arithmetic/imod.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , imod } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `imod(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `imod(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '1' , '0' ) ;
1618
test( macro , '0' , '-1' , '0' ) ;

test/src/integer/arithmetic/imodn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , imodn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = imodn( a , B ) ;
79
t.is( stringify( a ) , C ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `imodn(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `imodn(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 1 , '0' ) ;
1416
test( macro , '0' , -1 , '0' ) ;

test/src/integer/arithmetic/imul.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , imul } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `imul(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `imul(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '0' , '0' ) ;
1618
test( macro , '0' , '1' , '0' ) ;

test/src/integer/arithmetic/imuln.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , imuln } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = imuln( a , B ) ;
79
t.is( stringify( a ) , C ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `imuln(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `imuln(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 0 , '0' ) ;
1416
test( macro , '0' , 1 , '0' ) ;

test/src/integer/arithmetic/ipow.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/src/integer/arithmetic/ipown.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/src/integer/arithmetic/isub.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava' ;
22
import { parse , stringify , isub } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const b = parse( B ) ;
@@ -10,7 +12,7 @@ function macro ( t , A , B , C ) {
1012
t.is( stringify( c ) , C ) ;
1113
}
1214

13-
macro.title = ( _ , A , B , C ) => `isub(${A},${B}) = ${C}` ;
15+
macro.title = ( _ , A , B , C ) => `isub(${fmt(A)},${fmt(B)}) = ${fmt(C)}` ;
1416

1517
test( macro , '0' , '0' , '0' ) ;
1618
test( macro , '0' , '1' , '-1' ) ;

test/src/integer/arithmetic/isubn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import test from 'ava' ;
22
import { parse , stringify , isubn } from '../../../../src' ;
33

4+
const fmt = x => x.length <= 40 ? x : x.slice(0,19) + '..' + x.slice(-19);
5+
46
function macro ( t , A , B , C ) {
57
const a = parse( A ) ;
68
const c = isubn( a , B ) ;
79
t.is( stringify( a ) , C ) ;
810
t.is( stringify( c ) , C ) ;
911
}
1012

11-
macro.title = ( _ , A , B , C ) => `isubn(${A},${B}) = ${C}` ;
13+
macro.title = ( _ , A , B , C ) => `isubn(${fmt(A)},${B}) = ${fmt(C)}` ;
1214

1315
test( macro , '0' , 0 , '0' ) ;
1416
test( macro , '0' , 1 , '-1' ) ;

0 commit comments

Comments
 (0)