Browse Source

Add some Promise testcases

pull/1864/head
Sami Vaarala 7 years ago
parent
commit
9b48c521f4
  1. 27
      tests/ecmascript/test-bi-promise-constructor-all-empty.js
  2. 0
      tests/ecmascript/test-bi-promise-constructor-all-fulfill.js
  3. 0
      tests/ecmascript/test-bi-promise-constructor-all-iterable-error.js
  4. 0
      tests/ecmascript/test-bi-promise-constructor-all-iterable.js
  5. 0
      tests/ecmascript/test-bi-promise-constructor-all-reject.js
  6. 29
      tests/ecmascript/test-bi-promise-constructor-all-thenable.js
  7. 5
      tests/ecmascript/test-bi-promise-constructor-properties.js
  8. 0
      tests/ecmascript/test-bi-promise-constructor-race-fulfill-iterable-error.js
  9. 0
      tests/ecmascript/test-bi-promise-constructor-race-fulfill-iterable.js
  10. 0
      tests/ecmascript/test-bi-promise-constructor-race-fulfill-multiple.js
  11. 0
      tests/ecmascript/test-bi-promise-constructor-race-fulfill-reject-none.js
  12. 0
      tests/ecmascript/test-bi-promise-constructor-race-fulfill-single.js
  13. 0
      tests/ecmascript/test-bi-promise-constructor-race-reject-multiple.js
  14. 0
      tests/ecmascript/test-bi-promise-constructor-race-reject-single.js
  15. 32
      tests/ecmascript/test-bi-promise-constructor-reject-noarg.js
  16. 25
      tests/ecmascript/test-bi-promise-constructor-resolve-noarg.js
  17. 39
      tests/ecmascript/test-bi-promise-constructor-retval.js
  18. 34
      tests/ecmascript/test-bi-promise-resolve-self-resolution-settled.js

27
tests/ecmascript/test-bi-promise-constructor-all-empty.js

@ -0,0 +1,27 @@
/*---
{
"skip": true
}
---*/
/*===
done
fulfill
object
[object Array]
0
===*/
// Empty list is an important corner case, and also exercises the specific
// .all() path where an immediate completion is checked for.
Promise.all([]).then(function (v) {
print('fulfill');
print(typeof v);
print(Object.prototype.toString.call(v));
print(v.length);
}, function (e) {
print('reject:', e);
});
print('done');

0
tests/ecmascript/test-bi-promise-all-fulfill.js → tests/ecmascript/test-bi-promise-constructor-all-fulfill.js

0
tests/ecmascript/test-bi-promise-all-iterable-error.js → tests/ecmascript/test-bi-promise-constructor-all-iterable-error.js

0
tests/ecmascript/test-bi-promise-all-iterable.js → tests/ecmascript/test-bi-promise-constructor-all-iterable.js

0
tests/ecmascript/test-bi-promise-all-reject.js → tests/ecmascript/test-bi-promise-constructor-all-reject.js

29
tests/ecmascript/test-bi-promise-constructor-all-thenable.js

@ -0,0 +1,29 @@
/*---
{
"skip": true
}
---*/
/*===
done
O1.then
O2.then
Promise.all then
2 123 234
===*/
var O1CB, O2CB;
var O1 = { then: function (cb) { print('O1.then'); O1CB = cb; } };
var O2 = { then: function (cb) { print('O2.then'); O2CB = cb; } };
var P = Promise.all([ O1, O2 ]);
P.then(function (v) {
print('Promise.all then');
print(v.length, v[0], v[1]);
});
Promise.resolve().then(function () {
O1CB(123);
O2CB(234);
});
print('done');

5
tests/ecmascript/test-bi-promise-constructor-properties.js

@ -14,6 +14,7 @@ Promise
true
true
propdesc Promise: value=function:Promise, writable=true, enumerable=false, configurable=true
true
- properties
propdesc length: value=1, writable=false, enumerable=false, configurable=true
propdesc name: value="Promise", writable=false, enumerable=false, configurable=true
@ -22,6 +23,7 @@ propdesc all: value=function:all, writable=true, enumerable=false, configurable=
propdesc race: value=function:race, writable=true, enumerable=false, configurable=true
propdesc reject: value=function:reject, writable=true, enumerable=false, configurable=true
propdesc resolve: value=function:resolve, writable=true, enumerable=false, configurable=true
done
===*/
// General.
@ -34,6 +36,7 @@ print(Promise.name);
print('Promise' in GLOBAL);
print(Object.getPrototypeOf(Promise) === Function.prototype);
print(Test.getPropDescString(GLOBAL, 'Promise'));
print(Object.getPrototypeOf(new Promise(function () {})) === Promise.prototype);
print('- properties');
print(Test.getPropDescString(Promise, 'length'));
@ -44,3 +47,5 @@ print(Test.getPropDescString(Promise, 'race'));
print(Test.getPropDescString(Promise, 'reject'));
print(Test.getPropDescString(Promise, 'resolve'));
// @@species separately
print('done');

0
tests/ecmascript/test-bi-promise-race-iterable-error.js → tests/ecmascript/test-bi-promise-constructor-race-fulfill-iterable-error.js

0
tests/ecmascript/test-bi-promise-race-iterable.js → tests/ecmascript/test-bi-promise-constructor-race-fulfill-iterable.js

0
tests/ecmascript/test-bi-promise-race-fulfill-multiple.js → tests/ecmascript/test-bi-promise-constructor-race-fulfill-multiple.js

0
tests/ecmascript/test-bi-promise-race-fulfill-reject-none.js → tests/ecmascript/test-bi-promise-constructor-race-fulfill-reject-none.js

0
tests/ecmascript/test-bi-promise-race-fulfill-single.js → tests/ecmascript/test-bi-promise-constructor-race-fulfill-single.js

0
tests/ecmascript/test-bi-promise-race-reject-multiple.js → tests/ecmascript/test-bi-promise-constructor-race-reject-multiple.js

0
tests/ecmascript/test-bi-promise-race-reject-single.js → tests/ecmascript/test-bi-promise-constructor-race-reject-single.js

32
tests/ecmascript/test-bi-promise-constructor-reject-noarg.js

@ -0,0 +1,32 @@
/*---
{
"skip": true
}
---*/
/*===
done
fulfill, values match true
2 undefined undefined
===*/
// Missing argument and void 0 are handled the same.
var P = Promise.reject();
var Q = Promise.reject(void 0);
var T1 = P.catch(function (e) {
return e;
});
var T2 = Q.catch(function (e) {
return e;
});
Promise.all([ T1, T2 ]).then(function (v) {
print('fulfill, values match', v[0] === v[1]);
print(v.length, v[0], v[1]);
}, function (e) {
print('reject:', e);
});
print('done');

25
tests/ecmascript/test-bi-promise-constructor-resolve-noarg.js

@ -0,0 +1,25 @@
/*---
{
"skip": true
}
---*/
/*===
done
fulfill, values match true
2 undefined undefined
===*/
// Missing argument and void 0 are handled the same.
var P = Promise.resolve();
var Q = Promise.resolve(void 0);
Promise.all([ P, Q ]).then(function (v) {
print('fulfill, values match', v[0] === v[1]);
print(v.length, v[0], v[1]);
}, function (e) {
print('reject:', e);
});
print('done');

39
tests/ecmascript/test-bi-promise-constructor-retval.js

@ -0,0 +1,39 @@
/*---
{
"skip": true
}
---*/
/*===
done
Q fulfill: 321
===*/
// Promise executor return value has no effect on promise value.
var resolveP, rejectP;
var resolveQ, rejectQ;
var P = new Promise(function (resolve, reject) {
resolveP = resolve;
rejectP = reject;
return 123; // return value won't resolve P
});
P.then(function (v) {
print('P fulfill:', v);
}, function (e) {
print('P reject:', e);
});
var Q = new Promise(function (resolve, reject) {
resolveQ = resolve;
rejectQ = reject;
return 123;
});
Q.then(function (v) {
print('Q fulfill:', v);
}, function (e) {
print('Q reject:', e);
});
resolveQ(321);
print('done');

34
tests/ecmascript/test-bi-promise-resolve-self-resolution-settled.js

@ -0,0 +1,34 @@
/*---
{
"skip": true
}
---*/
/*===
ignored
done
fulfill: 123
===*/
var resolveFn;
var P = new Promise(function (resolve, reject) {
resolveFn = resolve;
});
P.then(function (v) {
print('fulfill:', v);
}, function (e) {
print('reject:', e.name);
});
resolveFn(123);
// Self resolution after already being settled is a no-op.
try {
resolveFn(P);
print('ignored');
} catch (e) {
print('should not happen:', e);
}
print('done');
Loading…
Cancel
Save