summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Promise/prototype/catch/this-value-obj-coercible.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Promise/prototype/catch/this-value-obj-coercible.js')
-rw-r--r--js/src/tests/test262/built-ins/Promise/prototype/catch/this-value-obj-coercible.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Promise/prototype/catch/this-value-obj-coercible.js b/js/src/tests/test262/built-ins/Promise/prototype/catch/this-value-obj-coercible.js
new file mode 100644
index 0000000000..4f71abec7a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/prototype/catch/this-value-obj-coercible.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-promise.prototype.catch
+description: >
+ Promise.prototype.catch called with an object-coercible `this` value
+info: |
+ 1. Let promise be the this value.
+ 2. Return ? Invoke(promise, "then", «undefined, onRejected»).
+
+ 7.3.18 Invoke
+
+ 1. Assert: IsPropertyKey(P) is true.
+ 2. If argumentsList was not passed, let argumentsList be a new empty List.
+ 3. Let func be ? GetV(V, P).
+ 4. Return ? Call(func, V, argumentsList).
+
+ 7.3.2 GetV
+
+ 1. Assert: IsPropertyKey(P) is true.
+ 2. Let O be ? ToObject(V).
+features: [Symbol]
+---*/
+
+var booleanCount = 0;
+Boolean.prototype.then = function() {
+ booleanCount += 1;
+};
+Promise.prototype.catch.call(true);
+assert.sameValue(booleanCount, 1, 'boolean');
+
+var numberCount = 0;
+Number.prototype.then = function() {
+ numberCount += 1;
+};
+Promise.prototype.catch.call(34);
+assert.sameValue(numberCount, 1, 'number');
+
+var stringCount = 0;
+String.prototype.then = function() {
+ stringCount += 1;
+};
+Promise.prototype.catch.call('');
+assert.sameValue(stringCount, 1, 'string');
+
+var symbolCount = 0;
+Symbol.prototype.then = function() {
+ symbolCount += 1;
+};
+Promise.prototype.catch.call(Symbol());
+assert.sameValue(symbolCount, 1, 'symbol');
+
+reportCompare(0, 0);