Debian Codegraph @

js/src/tests/test262/built-ins/NativeErrors/SuppressedError/order-of-args-evaluation.js

raw
1 // |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) -- explicit-resource-management is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2023 Ron Buckton. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-suppressederror-constructor
7 description: >
8 Process arguments in superclass-then-subclass order
9 info: |
10 SuppressedError ( error, suppressed, message )
11
12 3. If message is not undefined, then
13 a. Let messageString be ? ToString(message).
14 b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", messageString).
15 4. Perform CreateNonEnumerableDataPropertyOrThrow(O, "error", error).
16 5. Perform CreateNonEnumerableDataPropertyOrThrow(O, "suppressed", suppressed).
17
18 features: [explicit-resource-management, Symbol.iterator]
19 ---*/
20
21 let messageStringified = false;
22 const message = {
23 toString() {
24 messageStringified = true;
25 return '';
26 }
27 };
28 const error = {};
29 const suppressed = {};
30
31 const e = new SuppressedError(error, suppressed, message);
32
33 assert.sameValue(messageStringified, true);
34 const keys = Object.getOwnPropertyNames(e);
35
36 // Allow implementation-defined properties before "message" and after "suppressed".
37
38 const messageIndex = keys.indexOf("message");
39 assert.notSameValue(messageIndex, -1, "Expected 'message' to be defined");
40
41 const errorIndex = keys.indexOf("error");
42 assert.sameValue(errorIndex, messageIndex + 1, "Expected 'error' to be defined after 'message'");
43
44 const suppressedIndex = keys.indexOf("suppressed");
45 assert.sameValue(suppressedIndex, errorIndex + 1, "Expected 'suppressed' to be defined after 'error'");
46
47 reportCompare(0, 0);