Debian Codegraph @

js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_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-exotic-objects-defineownproperty-p-desc
6 info: If ToUint32(length) !== ToNumber(length), throw RangeError
7 es5id: 15.4.5.1_A1.1_T1
8 description: length in [4294967296, -1, 1.5]
9 ---*/
10
11 try {
12 var x = [];
13 x.length = 4294967296;
14 throw new Test262Error('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length));
15 } catch (e) {
16 assert.sameValue(
17 e instanceof RangeError,
18 true,
19 'The result of evaluating (e instanceof RangeError) is expected to be true'
20 );
21 }
22
23 try {
24 x = [];
25 x.length = -1;
26 throw new Test262Error('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length));
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 x = [];
37 x.length = 1.5;
38 throw new Test262Error('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length));
39 } catch (e) {
40 assert.sameValue(
41 e instanceof RangeError,
42 true,
43 'The result of evaluating (e instanceof RangeError) is expected to be true'
44 );
45 }
46
47 reportCompare(0, 0);