@@ -34,14 +34,24 @@ function testVersions([input, type], expected) {
3434function testPackFormats ( ) {
3535 const formatsTests = fs . readFileSync ( path . join ( __dirname , 'pack-formats-tests.txt' ) , { 'encoding' : 'utf-8' } )
3636 for ( const line of formatsTests . split ( '\n' ) ) {
37- const parts = line . match ( / ^ " ( .* ) " \( ( . ) \) ( \w + ) / )
37+ const parts = line . match ( / ^ " ( .* ) " \( ( r | d | r , d | - ) \) ( \w + | \w + , \w + ) / )
3838 if ( ! parts )
3939 continue
4040
41- const input = parts [ 1 ] || "[blank]"
42- const type = { 'r' : 'resource' , 'd' : 'data' , '-' : undefined } [ parts [ 2 ] ]
43- const result = parts [ 3 ] === 'none' ? undefined : parts [ 3 ] === 'null' ? null : + parts [ 3 ]
44- testPackFormat ( input , type , result )
41+ const getAns = ans => ans === 'none' ? undefined : ans === 'null' ? null : + ans
42+ const [ , lineName , lineType , lineAns ] = parts
43+ const input = lineName || "[blank]"
44+ const type = { 'r' : 'resource' , 'd' : 'data' , 'b' : 'both' , '-' : undefined } [ lineType ]
45+ if ( type === 'both' ) {
46+ // multiple: data AND resource
47+ const [ resourceAns , dataAns ] = lineAns . split ( ',' )
48+ testPackFormat ( input , type , getAns ( resourceAns ) )
49+ testPackFormat ( input , type , getAns ( dataAns ) )
50+ }
51+ else {
52+ // either data OR resource
53+ testPackFormat ( input , type , getAns ( lineAns ) )
54+ }
4555 }
4656}
4757
0 commit comments