@@ -139,39 +139,41 @@ eval:11:in \`<main>'`);
139139 } ) . toThrowError ( "Ruby APIs that may rewind the VM stack are prohibited" ) ;
140140 } ) ;
141141
142- test . each ( [
143- `JS::RubyVM.evalAsync("")` ,
144- ] ) ( "nested VM rewinding operation should throw fatal error (async)" , async ( code ) => {
145- // Supress bugreport message triggered by the fatal error inside evalAsync
146- const vm = await initRubyVM ( { suppressStderr : true } ) ;
147- const setVM = vm . eval ( `proc { |vm| JS::RubyVM = vm }` ) ;
148- setVM . call ( "call" , vm . wrap ( vm ) ) ;
142+ test . each ( [ `JS::RubyVM.evalAsync("")` ] ) (
143+ "nested VM rewinding operation should throw fatal error (async)" ,
144+ async ( code ) => {
145+ // Supress bugreport message triggered by the fatal error inside evalAsync
146+ const vm = await initRubyVM ( { suppressStderr : true } ) ;
147+ const setVM = vm . eval ( `proc { |vm| JS::RubyVM = vm }` ) ;
148+ setVM . call ( "call" , vm . wrap ( vm ) ) ;
149149
150- // HACK: We need to capture all promises to avoid unhandled promise rejection
151- const promises : Promise < any > [ ] = [ ]
152- const _Promise = global . Promise
153- const spy = jest . spyOn ( global , "Promise" )
154- . mockImplementation ( ( future ) => {
155- const promise = new _Promise ( future )
156- promises . push ( promise )
157- return promise
158- } )
150+ // HACK: We need to capture all promises to avoid unhandled promise rejection
151+ const promises : Promise < any > [ ] = [ ] ;
152+ const _Promise = global . Promise ;
153+ const spy = jest . spyOn ( global , "Promise" ) . mockImplementation ( ( future ) => {
154+ const promise = new _Promise ( future ) ;
155+ promises . push ( promise ) ;
156+ return promise ;
157+ } ) ;
159158
160- vm . evalAsync ( code )
159+ vm . evalAsync ( code ) ;
161160
162- const rejections : Error [ ] = [ ]
163- for ( const promise of promises ) {
164- try {
165- await promise
166- } catch ( e ) {
167- rejections . push ( e )
161+ const rejections : Error [ ] = [ ] ;
162+ for ( const promise of promises ) {
163+ try {
164+ await promise ;
165+ } catch ( e ) {
166+ rejections . push ( e ) ;
167+ }
168168 }
169- }
170169
171- spy . mockReset ( )
170+ spy . mockReset ( ) ;
172171
173- expect ( rejections [ 0 ] . message ) . toMatch ( "Ruby APIs that may rewind the VM stack are prohibited" )
174- } ) ;
172+ expect ( rejections [ 0 ] . message ) . toMatch (
173+ "Ruby APIs that may rewind the VM stack are prohibited"
174+ ) ;
175+ }
176+ ) ;
175177
176178 test ( "caught raise in nested eval is ok" , async ( ) => {
177179 const vm = await initRubyVM ( ) ;
0 commit comments