@@ -109,6 +109,18 @@ const localFunctions = {
109109
110110 throwError : function ( ) {
111111 throw new Error ( 'whatever' )
112+ } ,
113+
114+ throwUndefined : function ( ) {
115+ throw undefined
116+ } ,
117+
118+ throwNull : function ( ) {
119+ throw null
120+ } ,
121+
122+ throwZero : function ( ) {
123+ throw 0
112124 }
113125}
114126
@@ -302,17 +314,62 @@ test('ReferenceError error', async function(t) {
302314 }
303315} )
304316
305- // test('throw new Error()', async function(t) {
306- // try {
307- // remoteFunctions.throwError()
308- // t.true(false)
309- // } catch (e) {
310- // t.true(e instanceof Error)
311- // }
312- // try {
313- // await remoteFunctions.throwError()
314- // t.true(false)
315- // } catch (e) {
316- // t.true(e instanceof Error)
317- // }
318- // })
317+ test ( 'throw new Error()' , async function ( t ) {
318+ try {
319+ localFunctions . throwError ( )
320+ t . true ( false )
321+ } catch ( e ) {
322+ t . true ( e instanceof Error )
323+ }
324+ try {
325+ await remoteFunctions . throwError ( )
326+ t . true ( false )
327+ } catch ( e ) {
328+ t . true ( e instanceof Error )
329+ }
330+ } )
331+
332+ test ( 'throwUndefined' , async function ( t ) {
333+ try {
334+ localFunctions . throwUndefined ( )
335+ t . true ( false )
336+ } catch ( e ) {
337+ t . is ( e , undefined )
338+ }
339+ try {
340+ await remoteFunctions . throwUndefined ( )
341+ t . true ( false )
342+ } catch ( e ) {
343+ t . is ( e , null )
344+ }
345+ } )
346+
347+ test ( 'throwNull' , async function ( t ) {
348+ try {
349+ localFunctions . throwNull ( )
350+ t . true ( false )
351+ } catch ( e ) {
352+ t . is ( e , null )
353+ }
354+ try {
355+ await remoteFunctions . throwNull ( )
356+ t . true ( false )
357+ } catch ( e ) {
358+ t . is ( e , null )
359+ }
360+ } )
361+
362+ test ( 'throwZero' , async function ( t ) {
363+ try {
364+ localFunctions . throwZero ( )
365+ t . true ( false )
366+ } catch ( e ) {
367+ t . is ( e , 0 )
368+ }
369+ try {
370+ await remoteFunctions . throwZero ( 'lel' )
371+ t . true ( false )
372+ } catch ( e ) {
373+ t . is ( e , null )
374+ }
375+ } )
0 commit comments