js/src/jit-test/tests/parser/bug-889628.js

Thu, 15 Jan 2015 21:13:52 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:13:52 +0100
branch
TOR_BUG_9701
changeset 12
7540298fafa1
permissions
-rw-r--r--

Remove forgotten relic of ABI crash risk averse overloaded method change.

     1 // Destructuring assignment to eval or arguments in destructuring is a SyntaxError
     3 load(libdir + "asserts.js");
     5 var patterns = [
     6     "[_]",
     7     "[a, b, _]",
     8     "[[_]]",
     9     "[[], [{}, [_]]]",
    10     "{x:_}",
    11     "{x:y, z:_}",
    12     "{0:_}",
    13     "{_}",
    14     //"[..._]"
    15 ];
    17 // If the assertion below fails, congratulations! It means you have added
    18 // spread operator support to destructuring assignment. Simply uncomment the
    19 // "[..._]" case above. Then delete this comment and assertion.
    20 assertThrowsInstanceOf(() => Function("[...x] = [1]"), ReferenceError);
    22 for (var pattern of patterns) {
    23     var stmt = pattern + " = obj";
    24     if (stmt[0] == "{")
    25         stmt = "(" + stmt + ")";
    26     stmt += ";"
    28     // stmt is a legal statement...
    29     Function(stmt);
    31     // ...but not if you replace _ with one of these two names.
    32     for (var name of ["eval", "arguments"]) {
    33         var s = stmt.replace("_", name);
    34         assertThrowsInstanceOf(() => Function(s), SyntaxError);
    35         assertThrowsInstanceOf(() => eval(s), SyntaxError);
    36         assertThrowsInstanceOf(() => eval("'use strict'; " + s), SyntaxError);
    37     }
    38 }

mercurial