summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/push/S15.4.4.7_A3.js
blob: cd918e018034b9eccbb57388d9c2a8fc96e53896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: Check ToLength(length) for Array object
esid: sec-array.prototype.push
description: If ToUint32(length) !== length, throw RangeError
---*/

var x = [];
x.length = 4294967295;

var push = x.push();
assert.sameValue(push, 4294967295, 'The value of push is expected to be 4294967295');

try {
  x.push("x");
  throw new Test262Error('#2.1: x = []; x.length = 4294967295; x.push("x") throw RangeError. Actual: ' + (push));
} catch (e) {
  assert.sameValue(
    e instanceof RangeError,
    true,
    'The result of evaluating (e instanceof RangeError) is expected to be true'
  );
}

assert.sameValue(x[4294967295], "x", 'The value of x[4294967295] is expected to be "x"');
assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295');

reportCompare(0, 0);