Debian Codegraph @

js/src/tests/test262/built-ins/Promise/try/ctx-ctor.js

raw
1 // |reftest| shell-option(--enable-promise-try) skip-if(!Promise.try||!xulRuntime.shell) -- promise-try is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Jordan Harband. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 description: Promise.try produces instances of the receiver
7 esid: sec-promise.try
8 features: [promise-try, class]
9 ---*/
10
11 var executor = null;
12 var callCount = 0;
13
14 class SubPromise extends Promise {
15 constructor(a) {
16 super(a);
17 executor = a;
18 callCount += 1;
19 }
20 }
21
22 var instance = Promise.try.call(SubPromise, function () {});
23
24 assert.sameValue(instance.constructor, SubPromise);
25 assert.sameValue(instance instanceof SubPromise, true);
26
27 assert.sameValue(callCount, 1);
28 assert.sameValue(typeof executor, 'function');
29
30 reportCompare(0, 0);