Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Reflect/set/symbol-property.js

raw
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.13
5 description: >
6 Sets the new value.
7 info: |
8 26.1.13 Reflect.set ( target, propertyKey, V [ , receiver ] )
9
10 ...
11 2. Let key be ToPropertyKey(propertyKey).
12 ...
13
14 7.1.14 ToPropertyKey ( argument )
15
16 ...
17 3. If Type(key) is Symbol, then
18 a. Return key.
19 ...
20 features: [Symbol]
21 ---*/
22
23 var o1 = {};
24 var s = Symbol('1');
25 var result = Reflect.set(o1, s, 42);
26 assert.sameValue(result, true, 'returns true on a successful setting');
27 assert.sameValue(o1[s], 42, 'sets the new value');
28
29 var o2 = {};
30 o2[s] = 43;
31 var receiver = {};
32 receiver[s] = 44;
33 var result = Reflect.set(o2, s, 42, receiver);
34 assert.sameValue(result, true, 'returns true on a successful setting');
35 assert.sameValue(o2[s], 43, 'with a receiver, does not set a value on target');
36 assert.sameValue(receiver[s], 42, 'sets the new value on the receiver');