summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/values/return-order.js
blob: 073baf8b38dbcd82c610aa6fb3d6f55c3b06846c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2019 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-object.values
description: Object.values enumeration order
features: [for-in-order]
includes: [compareArray.js]
---*/

var o = {
  p1: 'p1',
  p2: 'p2',
  p3: 'p3',
};

// This getter will be triggered during enumeration, but the property it adds should not be enumerated.
Object.defineProperty(o, 'add', {
  enumerable: true,
  get: function () {
    o.extra = 'extra';
    return 'add';
  }
});

o.p4 = 'p4';

o[2] = '2';
o[0] = '0';
o[1] = '1';

delete o.p1;
delete o.p3;
o.p1 = 'p1';


var actual = Object.values(o);

var expected = ['0', '1', '2', 'p2', 'add', 'p4', 'p1'];

assert.compareArray(actual, expected);

reportCompare(0, 0);