Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / Set / tonumber-value-throws.js
blob3093f328bc7c7cd5fe4fe26224a251efab625bc0
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   Returns abrupt from ToNumber(value)
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       i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
15       ii. Return true.
16   ...
18   IntegerIndexedElementSet ( O, index, value )
20   Assert: O is an Integer-Indexed exotic object.
21   Assert: Type(index) is Number.
22   If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
23   Otherwise, let numValue be ? ToNumber(value).
24   ...
25 includes: [testTypedArray.js]
26 features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
27 ---*/
29 testWithTypedArrayConstructors(function(TA) {
30   let sample = new TA([42]);
32   let obj = {
33     valueOf() {
34       throw new Test262Error();
35     }
36   };
38   assert.throws(Test262Error, function() {
39     sample["0"] = obj;
40   });
42   assert.throws(Test262Error, function() {
43     sample["1.1"] = obj;
44   });
46   assert.throws(Test262Error, function() {
47     sample["-0"] = obj;
48   });
50   assert.throws(Test262Error, function() {
51     sample["-1"] = obj;
52   });
54   assert.throws(Test262Error, function() {
55     sample["1"] = obj;
56   });
58   assert.throws(Test262Error, function() {
59     sample["2"] = obj;
60   });
61 });
63 reportCompare(0, 0);