~ubuntu-branches/ubuntu/vivid/mozjs24/vivid

« back to all changes in this revision

Viewing changes to js/src/tests/ecma_5/Array/length-truncate-nonconfigurable.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Any copyright is dedicated to the Public Domain.
 
3
 * http://creativecommons.org/licenses/publicdomain/
 
4
 * Contributor:
 
5
 *   Jeff Walden <jwalden+code@mit.edu>
 
6
 */
 
7
 
 
8
//-----------------------------------------------------------------------------
 
9
var BUGNUMBER = 858381;
 
10
var summary =
 
11
  "Array length redefinition behavior with non-configurable elements";
 
12
 
 
13
print(BUGNUMBER + ": " + summary);
 
14
 
 
15
/**************
 
16
 * BEGIN TEST *
 
17
 **************/
 
18
 
 
19
var arr = [0, 1, 2];
 
20
Object.defineProperty(arr, 1, { configurable: false });
 
21
 
 
22
try
 
23
{
 
24
  Object.defineProperty(arr, "length", { value: 0, writable: false });
 
25
}
 
26
catch (e)
 
27
{
 
28
  assertEq(e instanceof TypeError, true,
 
29
           "must throw TypeError when array truncation would have to remove " +
 
30
           "non-configurable elements");
 
31
}
 
32
 
 
33
assertEq(arr.length, 2, "length is highest remaining index plus one");
 
34
 
 
35
var desc = Object.getOwnPropertyDescriptor(arr, "length");
 
36
assertEq(desc !== undefined, true);
 
37
 
 
38
assertEq(desc.value, 2);
 
39
assertEq(desc.writable, false);
 
40
assertEq(desc.enumerable, false);
 
41
assertEq(desc.configurable, false);
 
42
 
 
43
/******************************************************************************/
 
44
 
 
45
if (typeof reportCompare === "function")
 
46
  reportCompare(true, true);
 
47
 
 
48
print("Tests complete");