Debian Codegraph @

js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.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_T2
10 description: Use try statement. len = NaN, +/-Infinity
11 ---*/
12
13 try {
14 new Array(NaN);
15 throw new Test262Error('#1.1: new Array(NaN) throw RangeError. Actual: ' + (new Array(NaN)));
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(Number.POSITIVE_INFINITY);
26 throw new Test262Error('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.POSITIVE_INFINITY)));
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(Number.NEGATIVE_INFINITY);
37 throw new Test262Error('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.NEGATIVE_INFINITY)));
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);