File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1011,7 +1011,9 @@ export class Parser {
10111011 ) ;
10121012 }
10131013 ctx . generateError (
1014- `"Assertion error: ${ varName } is " + ${ this . options . assert } `
1014+ `"Assertion error: ${ varName } is " + ${ JSON . stringify (
1015+ this . options . assert . toString ( )
1016+ ) } `
10151017 ) ;
10161018 ctx . pushCode ( "}" ) ;
10171019 }
Original file line number Diff line number Diff line change @@ -1156,6 +1156,25 @@ function compositeParserTests(
11561156 throws ( ( ) => {
11571157 parser2 . parse ( buffer4 ) ;
11581158 } ) ;
1159+
1160+ const parser3 = new Parser ( )
1161+ . int16le ( "a" )
1162+ . int16le ( "b" )
1163+ . int16le ( "c" , {
1164+ assert ( this : { a : number ; b : number } , x : number | string ) {
1165+ return this . a + this . b === x ;
1166+ } ,
1167+ } ) ;
1168+
1169+ const buffer5 = hexToBuf ( "d2042e16001b" ) ;
1170+ doesNotThrow ( ( ) => {
1171+ parser3 . parse ( buffer5 ) ;
1172+ } ) ;
1173+
1174+ const buffer6 = hexToBuf ( "2e16001bd204" ) ;
1175+ throws ( ( ) => {
1176+ parser3 . parse ( buffer6 ) ;
1177+ } ) ;
11591178 } ) ;
11601179 } ) ;
11611180
You can’t perform that action at this time.
0 commit comments