Skip to content

Commit

Permalink
[Tests] Further ensure that Promise.resolve/reject work with a non-pr…
Browse files Browse the repository at this point in the history
…omise receiver.

Per #379 (comment)
  • Loading branch information
ljharb committed Dec 12, 2015
1 parent 3d5bc93 commit 20d978a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions test/promise/reject.js
Expand Up @@ -22,11 +22,12 @@ describe('Promise.reject', function () {
});

it('throws when receiver is a primitive', function () {
expect(function () { Promise.reject.call(); }).to['throw']();
expect(function () { Promise.reject.call(null); }).to['throw']();
expect(function () { Promise.reject.call(''); }).to['throw']();
expect(function () { Promise.reject.call(42); }).to['throw']();
expect(function () { Promise.reject.call(false); }).to['throw']();
expect(function () { Promise.reject.call(true); }).to['throw']();
var promise = Promise.reject();
expect(function () { Promise.reject.call(undefined, promise); }).to['throw']();
expect(function () { Promise.reject.call(null, promise); }).to['throw']();
expect(function () { Promise.reject.call('', promise); }).to['throw']();
expect(function () { Promise.reject.call(42, promise); }).to['throw']();
expect(function () { Promise.reject.call(false, promise); }).to['throw']();
expect(function () { Promise.reject.call(true, promise); }).to['throw']();
});
});
13 changes: 7 additions & 6 deletions test/promise/resolve.js
Expand Up @@ -22,11 +22,12 @@ describe('Promise.resolve', function () {
});

it('throws when receiver is a primitive', function () {
expect(function () { Promise.resolve.call(); }).to['throw']();
expect(function () { Promise.resolve.call(null); }).to['throw']();
expect(function () { Promise.resolve.call(''); }).to['throw']();
expect(function () { Promise.resolve.call(42); }).to['throw']();
expect(function () { Promise.resolve.call(false); }).to['throw']();
expect(function () { Promise.resolve.call(true); }).to['throw']();
var promise = Promise.resolve();
expect(function () { Promise.resolve.call(undefined, promise); }).to['throw']();
expect(function () { Promise.resolve.call(null, promise); }).to['throw']();
expect(function () { Promise.resolve.call('', promise); }).to['throw']();
expect(function () { Promise.resolve.call(42, promise); }).to['throw']();
expect(function () { Promise.resolve.call(false, promise); }).to['throw']();
expect(function () { Promise.resolve.call(true, promise); }).to['throw']();
});
});

0 comments on commit 20d978a

Please sign in to comment.