js/src/tests/ecma_5/strict/15.4.4.8.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/strict/15.4.4.8.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +
     1.6 +/*
     1.7 + * Any copyright is dedicated to the Public Domain.
     1.8 + * http://creativecommons.org/licenses/publicdomain/
     1.9 + */
    1.10 +
    1.11 +function arr() {
    1.12 +  return Object.defineProperty([1, 2, 3], 0, {writable: false});
    1.13 +}
    1.14 +
    1.15 +function obj() {
    1.16 +  var o = {0: 1, 1: 2, 2: 3, length: 3};
    1.17 +  Object.defineProperty(o, 0, {writable: false});
    1.18 +  return o;
    1.19 +}
    1.20 +
    1.21 +assertEq(testLenientAndStrict('var a = arr(); a.reverse()',
    1.22 +                              raisesException(TypeError),
    1.23 +                              raisesException(TypeError)),
    1.24 +         true);
    1.25 +
    1.26 +assertEq(testLenientAndStrict('var o = obj(); Array.prototype.reverse.call(o)',
    1.27 +                              raisesException(TypeError),
    1.28 +                              raisesException(TypeError)),
    1.29 +         true);
    1.30 +
    1.31 +function agap() {
    1.32 +  var a = [1, 2, , 4];
    1.33 +  Object.defineProperty(a, 1, {configurable: false});
    1.34 +  return a;
    1.35 +}
    1.36 +
    1.37 +function ogap() {
    1.38 +  var o = {0: 1, 1: 2, /* no 2 */ 3: 4, length: 4};
    1.39 +  Object.defineProperty(o, 1, {configurable: false});
    1.40 +  return o;
    1.41 +}
    1.42 +
    1.43 +assertEq(testLenientAndStrict('var a = agap(); a.reverse()',
    1.44 +                              raisesException(TypeError),
    1.45 +                              raisesException(TypeError)),
    1.46 +         true);
    1.47 +
    1.48 +assertEq(testLenientAndStrict('var o = ogap(); Array.prototype.reverse.call(o)',
    1.49 +                              raisesException(TypeError),
    1.50 +                              raisesException(TypeError)),
    1.51 +         true);
    1.52 +
    1.53 +reportCompare(true, true);

mercurial