Debian Codegraph @

js/src/tests/test262/language/module-code/namespace/internals/own-property-keys-sort.js

raw
1 // |reftest| module
2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-module-namespace-exotic-objects-ownpropertykeys
6 description: >
7 The [[OwnPropertyKeys]] internal method reflects the sorted order
8 info: |
9 1. Let exports be a copy of the value of O's [[Exports]] internal slot.
10 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O).
11 3. Append all the entries of symbolKeys to the end of exports.
12 4. Return exports.
13 flags: [module]
14 features: [Reflect, Symbol.toStringTag]
15 ---*/
16
17 var x;
18 export { x as π }; // u03c0
19 export { x as az };
20 export { x as __ };
21 export { x as za };
22 export { x as Z };
23 export { x as \u03bc };
24 export { x as z };
25 export { x as zz };
26 export { x as a };
27 export { x as A };
28 export { x as aa };
29 export { x as λ }; // u03bb
30 export { x as _ };
31 export { x as $$ };
32 export { x as $ };
33 export default null;
34
35 import * as ns from './own-property-keys-sort.js';
36
37 var stringKeys = Object.getOwnPropertyNames(ns);
38
39 assert.sameValue(stringKeys.length, 16);
40 assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"');
41 assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"');
42 assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"');
43 assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"');
44 assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"');
45 assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"');
46 assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"');
47 assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"');
48 assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"');
49 assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"');
50 assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"');
51 assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"');
52 assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"');
53 assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"');
54 assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"');
55 assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"');
56
57 var allKeys = Reflect.ownKeys(ns);
58 assert(
59 allKeys.length >= 17,
60 'at least as many keys as defined by the module and the specification'
61 );
62 assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"');
63 assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"');
64 assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"');
65 assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"');
66 assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"');
67 assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"');
68 assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"');
69 assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"');
70 assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"');
71 assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"');
72 assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"');
73 assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"');
74 assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"');
75 assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"');
76 assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"');
77 assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"');
78 assert(
79 allKeys.indexOf(Symbol.toStringTag) > 15,
80 'keys array includes Symbol.toStringTag'
81 );
82
83 reportCompare(0, 0);