@@ -882,20 +882,20 @@ var tests = [
882
882
) ;
883
883
}
884
884
} ,
885
- {
886
- name : "Promise.all called with empty iterator, calls Promise.resolve synchronously and passes abrupt completion to reject handler" ,
887
- body : function ( index ) {
888
- function FakePromise ( fn ) {
889
- function resolve ( ) { echo ( `Test #${ index } - resolve called` ) ; throw new Error ( 'oops' ) ; }
890
- function reject ( e ) { echo ( `Test #${ index } - reject called: ${ e . message } ` ) }
891
- fn ( resolve , reject ) ;
892
- this . then = function ( onResolve , onReject ) { } ;
893
- }
885
+ {
886
+ name : "Promise.all called with empty iterator, calls Promise.resolve synchronously and passes abrupt completion to reject handler" ,
887
+ body : function ( index ) {
888
+ function FakePromise ( fn ) {
889
+ function resolve ( ) { echo ( `Test #${ index } - resolve called` ) ; throw new Error ( 'oops' ) ; }
890
+ function reject ( e ) { echo ( `Test #${ index } - reject called: ${ e . message } ` ) }
891
+ fn ( resolve , reject ) ;
892
+ this . then = function ( onResolve , onReject ) { } ;
893
+ }
894
894
895
- FakePromise . resolve = function ( ) { } ;
896
- Promise . all . call ( FakePromise , [ ] ) ;
897
- }
898
- } ,
895
+ FakePromise . resolve = function ( ) { } ;
896
+ Promise . all . call ( FakePromise , [ ] ) ;
897
+ }
898
+ } ,
899
899
{
900
900
name : "Promise.resolve called with a thenable calls then on the thenable" ,
901
901
body : function ( index ) {
@@ -1324,20 +1324,83 @@ var tests = [
1324
1324
e => echo ( `Test #${ index } - Failed - ${ JSON . stringify ( e ) } ` ) ) ;
1325
1325
}
1326
1326
} ,
1327
- {
1328
- name : "Promise.allsettled called with empty iterator, calls Promise.resolve synchronously and passes abrupt completion to reject handler" ,
1329
- body : function ( index ) {
1330
- function FakePromise ( fn ) {
1331
- function resolve ( ) { echo ( `Test #${ index } - resolve called` ) ; throw new Error ( 'oops' ) ; }
1332
- function reject ( e ) { echo ( `Test #${ index } - reject called: ${ e . message } ` ) }
1333
- fn ( resolve , reject ) ;
1334
- this . then = function ( onResolve , onReject ) { } ;
1335
- }
1327
+ {
1328
+ name : "Promise.allSettled called with empty iterator, calls Promise.resolve synchronously and passes abrupt completion to reject handler" ,
1329
+ body : function ( index ) {
1330
+ function FakePromise ( fn ) {
1331
+ function resolve ( ) { echo ( `Test #${ index } - resolve called` ) ; throw new Error ( 'oops' ) ; }
1332
+ function reject ( e ) { echo ( `Test #${ index } - reject called: ${ e . message } ` ) }
1333
+ fn ( resolve , reject ) ;
1334
+ this . then = function ( onResolve , onReject ) { } ;
1335
+ }
1336
+
1337
+ FakePromise . resolve = function ( ) { } ;
1338
+ Promise . allSettled . call ( FakePromise , [ ] ) ;
1339
+ }
1340
+ } ,
1341
+ {
1342
+ name : "Promise.allSettled gets the constructor's resolve function only once" ,
1343
+ body : function ( index ) {
1344
+ function FakePromise ( fn ) {
1345
+ fn ( function ( ) { } , function ( ) { } ) ;
1346
+ this . then = function ( onResolve , onReject ) { } ;
1347
+ }
1348
+
1349
+ Object . defineProperty ( FakePromise , 'resolve' , {
1350
+ get : function ( ) {
1351
+ echo ( `Test #${ index } - get constructor resolve` ) ;
1352
+ return function ( x ) {
1353
+ echo ( `Test #${ index } - constructor resolve called` ) ;
1354
+ return Promise . resolve ( x ) ;
1355
+ } ;
1356
+ }
1357
+ } ) ;
1358
+
1359
+ Promise . allSettled . call ( FakePromise , [ 1 , 2 ] ) ;
1360
+ }
1361
+ } ,
1362
+ {
1363
+ name : "Promise.all gets the constructor's resolve function only once" ,
1364
+ body : function ( index ) {
1365
+ function FakePromise ( fn ) {
1366
+ fn ( function ( ) { } , function ( ) { } ) ;
1367
+ this . then = function ( onResolve , onReject ) { } ;
1368
+ }
1369
+
1370
+ Object . defineProperty ( FakePromise , 'resolve' , {
1371
+ get : function ( ) {
1372
+ echo ( `Test #${ index } - get constructor resolve` ) ;
1373
+ return function ( x ) {
1374
+ echo ( `Test #${ index } - constructor resolve called` ) ;
1375
+ return Promise . resolve ( x ) ;
1376
+ } ;
1377
+ }
1378
+ } ) ;
1379
+
1380
+ Promise . all . call ( FakePromise , [ 1 , 2 ] ) ;
1381
+ }
1382
+ } ,
1383
+ {
1384
+ name : "Promise.race gets the constructor's resolve function only once" ,
1385
+ body : function ( index ) {
1386
+ function FakePromise ( fn ) {
1387
+ fn ( function ( ) { } , function ( ) { } ) ;
1388
+ this . then = function ( onResolve , onReject ) { } ;
1389
+ }
1390
+
1391
+ Object . defineProperty ( FakePromise , 'resolve' , {
1392
+ get : function ( ) {
1393
+ echo ( `Test #${ index } - get constructor resolve` ) ;
1394
+ return function ( x ) {
1395
+ echo ( `Test #${ index } - constructor resolve called` ) ;
1396
+ return Promise . resolve ( x ) ;
1397
+ } ;
1398
+ }
1399
+ } ) ;
1336
1400
1337
- FakePromise . resolve = function ( ) { } ;
1338
- Promise . allSettled . call ( FakePromise , [ ] ) ;
1339
- }
1340
- } ,
1401
+ Promise . race . call ( FakePromise , [ 1 , 2 ] ) ;
1402
+ }
1403
+ }
1341
1404
] ;
1342
1405
1343
1406
var index = 1 ;
0 commit comments