Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Reflect / ownKeys / return-on-corresponding-order.js
blob5285fcf35ac3ef6368b145cfc3e1521bf428fc11
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 26.1.11
5 description: >
6   Returns keys in their corresponding order.
7 info: |
8   26.1.11 Reflect.ownKeys ( target )
10   ...
11   2. Let keys be target.[[OwnPropertyKeys]]().
12   3. ReturnIfAbrupt(keys).
13   4. Return CreateArrayFromList(keys).
15   9.1.12 [[OwnPropertyKeys]] ( )
17   1. Let keys be a new empty List.
18   2. For each own property key P of O that is an integer index, in ascending
19   numeric index order
20     a. Add P as the last element of keys.
21   3. For each own property key P of O that is a String but is not an integer
22   index, in property creation order
23     a. Add P as the last element of keys.
24   4. For each own property key P of O that is a Symbol, in property creation
25   order
26     a. Add P as the last element of keys.
27   5. Return keys.
28 features: [Reflect, Symbol]
29 ---*/
32 var o = {};
33 o.p1 = 42;
34 o.p2 = 43;
36 var s1 = Symbol('1');
37 var s2 = Symbol('a');
38 o[s1] = 44;
39 o[s2] = 45;
41 o[2] = 46;
42 o[0] = 47;
43 o[1] = 48;
45 var result = Reflect.ownKeys(o);
47 assert.sameValue(result.length, 7);
48 assert.sameValue(result[0], '0');
49 assert.sameValue(result[1], '1');
50 assert.sameValue(result[2], '2');
51 assert.sameValue(result[3], 'p1');
52 assert.sameValue(result[4], 'p2');
53 assert.sameValue(result[5], s1);
54 assert.sameValue(result[6], s2);
56 reportCompare(0, 0);