Debian Codegraph @

js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-array-len
6 info: |
7 If the argument len is a Number and ToUint32(len) is not equal to len,
8 a RangeError exception is thrown
9 es5id: 15.4.2.2_A2.2_T1
10 description: Use try statement. len = -1, 4294967296, 4294967297
11 ---*/
12
13 try {
14 new Array(-1);
15 throw new Test262Error('#1.1: new Array(-1) throw RangeError. Actual: ' + (new Array(-1)));
16 } catch (e) {
17 assert.sameValue(
18 e instanceof RangeError,
19 true,
20 'The result of evaluating (e instanceof RangeError) is expected to be true'
21 );
22 }
23
24 try {
25 new Array(4294967296);
26 throw new Test262Error('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new Array(4294967296)));
27 } catch (e) {
28 assert.sameValue(
29 e instanceof RangeError,
30 true,
31 'The result of evaluating (e instanceof RangeError) is expected to be true'
32 );
33 }
34
35 try {
36 new Array(4294967297);
37 throw new Test262Error('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new Array(4294967297)));
38 } catch (e) {
39 assert.sameValue(
40 e instanceof RangeError,
41 true,
42 'The result of evaluating (e instanceof RangeError) is expected to be true'
43 );
44 }
45
46 reportCompare(0, 0);