2015-12-02 18:06:40 +01:00
|
|
|
// Copyright (C) 2015 André Bargull. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
es6id: 25.4.4.5
|
|
|
|
description: >
|
|
|
|
Throws a TypeError if `this` is not an Object.
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2015-12-02 18:06:40 +01:00
|
|
|
Promise.resolve ( x )
|
|
|
|
|
|
|
|
1. Let C be the this value.
|
|
|
|
2. If Type(C) is not Object, throw a TypeError exception.
|
|
|
|
...
|
|
|
|
features: [Symbol]
|
|
|
|
---*/
|
|
|
|
|
2018-02-15 21:11:21 +01:00
|
|
|
var promise = new Promise(function() {});
|
2015-12-02 18:06:40 +01:00
|
|
|
|
|
|
|
promise.constructor = undefined;
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Promise.resolve.call(undefined, promise);
|
|
|
|
}, "`this` value is undefined");
|
|
|
|
|
|
|
|
promise.constructor = null;
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Promise.resolve.call(null, promise);
|
|
|
|
}, "`this` value is null");
|
|
|
|
|
|
|
|
promise.constructor = true;
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Promise.resolve.call(true, promise);
|
|
|
|
}, "`this` value is a Boolean");
|
|
|
|
|
|
|
|
promise.constructor = 1;
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Promise.resolve.call(1, promise);
|
|
|
|
}, "`this` value is a Number");
|
|
|
|
|
|
|
|
promise.constructor = "";
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Promise.resolve.call("", promise);
|
|
|
|
}, "`this` value is a String");
|
|
|
|
|
|
|
|
var symbol = Symbol();
|
|
|
|
promise.constructor = symbol;
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Promise.resolve.call(symbol, promise);
|
|
|
|
}, "`this` value is a Symbol");
|