Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / Set / key-is-not-canonical-index.js
blob72d1f7769a24bfc6033ab5a9bd059a8b85e19747
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 numeric key is not a CanonicalNumericIndex
7 info: |
8   9.4.5.5 [[Set]] ( P, V, Receiver)
10   ...
11   2. If Type(P) is String, then
12     a. Let numericIndex be ! CanonicalNumericIndexString(P).
13     b. If numericIndex is not undefined, then
14   ...
15   3. Return ? OrdinarySet(O, P, V, Receiver).
16 includes: [testTypedArray.js]
17 features: [align-detached-buffer-semantics-with-web-reality, Reflect, TypedArray]
18 ---*/
20 var keys = [
21   "1.0",
22   "+1",
23   "1000000000000000000000",
24   "0.0000001"
27 testWithTypedArrayConstructors(function(TA) {
28   keys.forEach(function(key) {
29     var sample = new TA([42]);
31     assert.sameValue(
32       Reflect.set(sample, key, "ecma262"),
33       true,
34       'Reflect.set(sample, key, "ecma262") must return true'
35     );
36     assert.sameValue(sample[key], "ecma262", 'The value of sample[key] is "ecma262"');
38     assert.sameValue(
39       Reflect.set(sample, key, "es3000"),
40       true,
41       'Reflect.set(sample, key, "es3000") must return true'
42     );
43     assert.sameValue(sample[key], "es3000", 'The value of sample[key] is "es3000"');
45     Object.defineProperty(sample, key, {
46       writable: false,
47       value: undefined
48     });
49     assert.sameValue(
50       Reflect.set(sample, key, 42),
51       false,
52       'Reflect.set(sample, key, 42) must return false'
53     );
54     assert.sameValue(
55       sample[key], undefined, 'The value of sample[key] is expected to equal `undefined`'
56     );
57   });
58 });
60 reportCompare(0, 0);