js/src/tests/js1_8_1/regress/regress-509354.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_8_1/regress/regress-509354.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/*
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/licenses/publicdomain/
     1.7 + * Contributor: Jason Orendorff <jorendorff@mozilla.com>
     1.8 + */
     1.9 +
    1.10 +// Decompile destructuring argument named `arguments` correctly.
    1.11 +var actual = "" + function ([arguments]) {return arguments;};
    1.12 +compareSource('function ([arguments]) {return arguments;}', actual, "part 1");
    1.13 +
    1.14 +// Make sure the 'arguments' argument actually works.
    1.15 +var f = function ([arguments]) {return arguments + 1;};
    1.16 +reportCompare(3.25, f([2.25]), "part 2");
    1.17 +
    1.18 +// Throw SyntaxError when `arguments` appears twice in a destructuring parameter.
    1.19 +actual = "no exception";
    1.20 +try {
    1.21 +    eval('(function ([arguments, arguments]) {return arguments();})');
    1.22 +} catch (exc) {
    1.23 +    actual = exc.name;
    1.24 +}
    1.25 +reportCompare("SyntaxError", actual, "part 3");
    1.26 +
    1.27 +// And again...
    1.28 +actual = "no exception";
    1.29 +try {
    1.30 +    eval('(function ([a, b, arguments, d], [e, f, arguments]) {return arguments();})');
    1.31 +} catch (exc) {
    1.32 +    actual = exc.name;
    1.33 +}
    1.34 +reportCompare("SyntaxError", actual, "part 4");
    1.35 +
    1.36 +// The original test case from bug 509354. Don't crash.
    1.37 +try {
    1.38 +    eval('print(function([arguments,arguments,arguments,arguments,arguments,' +
    1.39 +         'arguments,arguments,arguments,arguments,arguments,arguments,' +
    1.40 +         'arguments,arguments,arguments,arguments,arguments]){})');
    1.41 +} catch (exc) {
    1.42 +}
    1.43 +reportCompare("no crash", "no crash", "part 5");
    1.44 +

mercurial