js/src/tests/test262/ch11/11.4/11.4.1/S11.4.1_A5.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch11/11.4/11.4.1/S11.4.1_A5.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +// Copyright 2011 Google Inc.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * A strict delete should either succeed, returning true, or it
     1.9 + * should fail by throwing a TypeError. Under no circumstances
    1.10 + * should a strict delete return false.
    1.11 + *
    1.12 + * @path ch11/11.4/11.4.1/S11.4.1_A5.js
    1.13 + * @description See if a strict delete returns false when deleting a
    1.14 + * non-standard property.
    1.15 + * @onlyStrict
    1.16 + */
    1.17 +
    1.18 +"use strict";
    1.19 +
    1.20 +var reNames = Object.getOwnPropertyNames(RegExp);
    1.21 +for (var i = 0, len = reNames.length; i < len; i++) {
    1.22 +  var reName = reNames[i];
    1.23 +  if (reName !== 'prototype') {
    1.24 +    var deleted = 'unassigned';
    1.25 +    try {
    1.26 +      deleted = delete RegExp[reName];
    1.27 +    } catch (err) {
    1.28 +      if (!(err instanceof TypeError)) {
    1.29 +        $ERROR('#1: strict delete threw a non-TypeError: ' + err);
    1.30 +      }
    1.31 +      // fall through
    1.32 +    }
    1.33 +    if (deleted === false) {
    1.34 +      $ERROR('#2: Strict delete returned false');
    1.35 +    }
    1.36 +  }
    1.37 +}
    1.38 +

mercurial