summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Reflect/set/symbol-property.js
blob: d6a5857ce7ec2c1464a004a0fee10041143482b2 (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
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.1.13
description: >
  Sets the new value.
info: |
  26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )

  ...
  2. Let key be ToPropertyKey(propertyKey).
  ...

  7.1.14 ToPropertyKey ( argument )

  ...
  3. If Type(key) is Symbol, then
    a. Return key.
  ...
features: [Reflect, Reflect.set, Symbol]
---*/

var o1 = {};
var s = Symbol('1');
var result = Reflect.set(o1, s, 42);
assert.sameValue(result, true, 'returns true on a successful setting');
assert.sameValue(o1[s], 42, 'sets the new value');

var o2 = {};
o2[s] = 43;
var receiver = {};
receiver[s] = 44;
var result = Reflect.set(o2, s, 42, receiver);
assert.sameValue(result, true, 'returns true on a successful setting');
assert.sameValue(o2[s], 43, 'with a receiver, does not set a value on target');
assert.sameValue(receiver[s], 42, 'sets the new value on the receiver');

reportCompare(0, 0);