@@ -8,8 +8,8 @@ const files = fs.readdirSync('./suites')
8
8
for ( const file of files ) {
9
9
if ( file . endsWith ( '.json' ) ) {
10
10
tests . push ( ...JSON . parse ( fs . readFileSync ( `./suites/${ file } ` ) . toString ( ) ) . filter ( i => typeof i !== 'string' ) . map ( i => {
11
- if ( Array . isArray ( i ) ) return i
12
- return [ i . rule , i . data || { } , i . result ]
11
+ if ( Array . isArray ( i ) ) return { rule : i [ 0 ] , data : i [ 1 ] || null , result : i [ 2 ] , description : JSON . stringify ( i [ 0 ] ) }
12
+ return i
13
13
} ) )
14
14
}
15
15
}
@@ -47,23 +47,23 @@ for (let i = 0; i < 8; i++) {
47
47
describe ( 'All of the compatible tests' , ( ) => {
48
48
for ( const testCase of tests ) {
49
49
for ( const engine of engines ) {
50
- test ( `${ engine [ 1 ] } ${ JSON . stringify ( testCase [ 0 ] ) } ${ JSON . stringify (
51
- testCase [ 1 ]
50
+ test ( `${ engine [ 1 ] } ${ JSON . stringify ( testCase . rule ) } ${ JSON . stringify (
51
+ testCase . data
52
52
) } `, async ( ) => {
53
- let result = await engine [ 0 ] . run ( testCase [ 0 ] , testCase [ 1 ] )
53
+ let result = await engine [ 0 ] . run ( testCase . rule , testCase . data )
54
54
if ( ( result || 0 ) . toNumber ) result = Number ( result )
55
55
if ( Array . isArray ( result ) ) result = result . map ( i => ( i || 0 ) . toNumber ? Number ( i ) : i )
56
- expect ( correction ( result ) ) . toStrictEqual ( testCase [ 2 ] )
56
+ expect ( correction ( result ) ) . toStrictEqual ( testCase . result )
57
57
} )
58
58
59
- test ( `${ engine [ 1 ] } ${ JSON . stringify ( testCase [ 0 ] ) } ${ JSON . stringify (
60
- testCase [ 1 ]
59
+ test ( `${ engine [ 1 ] } ${ JSON . stringify ( testCase . rule ) } ${ JSON . stringify (
60
+ testCase . data
61
61
) } (built)`, async ( ) => {
62
- const f = await engine [ 0 ] . build ( testCase [ 0 ] )
63
- let result = await f ( testCase [ 1 ] )
62
+ const f = await engine [ 0 ] . build ( testCase . rule )
63
+ let result = await f ( testCase . data )
64
64
if ( ( result || 0 ) . toNumber ) result = Number ( result )
65
65
if ( Array . isArray ( result ) ) result = result . map ( i => i . toNumber ? Number ( i ) : i )
66
- expect ( correction ( result ) ) . toStrictEqual ( testCase [ 2 ] )
66
+ expect ( correction ( result ) ) . toStrictEqual ( testCase . result )
67
67
} )
68
68
}
69
69
}
0 commit comments