Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / Set / key-is-symbol.js
blobfe624e47256090e17bffc68cdc3c2b9c9ff1f141
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
5 description: >
6   Use OrdinarySet if key is a Symbol
7 info: |
8   9.4.5.5 [[Set]] ( P, V, Receiver)
10   ...
11   2. If Type(P) is String, then
12   ...
13   3. Return ? OrdinarySet(O, P, V, Receiver).
14 includes: [testTypedArray.js]
15 features: [align-detached-buffer-semantics-with-web-reality, Reflect, Symbol, TypedArray]
16 ---*/
18 var s1 = Symbol("1");
19 var s2 = Symbol("2");
21 testWithTypedArrayConstructors(function(TA) {
22   var sample = new TA([42]);
24   assert.sameValue(
25     Reflect.set(sample, s1, "ecma262"),
26     true,
27     'Reflect.set(sample, "Symbol(\\"1\\")", "ecma262") must return true'
28   );
29   assert.sameValue(sample[s1], "ecma262", 'The value of sample[s1] is "ecma262"');
31   assert.sameValue(
32     Reflect.set(sample, s1, "es3000"),
33     true,
34     'Reflect.set(sample, "Symbol(\\"1\\")", "es3000") must return true'
35   );
36   assert.sameValue(sample[s1], "es3000", 'The value of sample[s1] is "es3000"');
38   Object.defineProperty(sample, s2, {
39     writable: false,
40     value: undefined
41   });
42   assert.sameValue(
43     Reflect.set(sample, s2, 42),
44     false,
45     'Reflect.set(sample, "Symbol(\\"2\\")", 42) must return false'
46   );
47   assert.sameValue(sample[s2], undefined, 'The value of sample[s2] is expected to equal `undefined`');
48 });
50 reportCompare(0, 0);