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

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/licenses/publicdomain/
michael@0 4 * Contributor: Jason Orendorff <jorendorff@mozilla.com>
michael@0 5 */
michael@0 6
michael@0 7 // Decompile destructuring argument named `arguments` correctly.
michael@0 8 var actual = "" + function ([arguments]) {return arguments;};
michael@0 9 compareSource('function ([arguments]) {return arguments;}', actual, "part 1");
michael@0 10
michael@0 11 // Make sure the 'arguments' argument actually works.
michael@0 12 var f = function ([arguments]) {return arguments + 1;};
michael@0 13 reportCompare(3.25, f([2.25]), "part 2");
michael@0 14
michael@0 15 // Throw SyntaxError when `arguments` appears twice in a destructuring parameter.
michael@0 16 actual = "no exception";
michael@0 17 try {
michael@0 18 eval('(function ([arguments, arguments]) {return arguments();})');
michael@0 19 } catch (exc) {
michael@0 20 actual = exc.name;
michael@0 21 }
michael@0 22 reportCompare("SyntaxError", actual, "part 3");
michael@0 23
michael@0 24 // And again...
michael@0 25 actual = "no exception";
michael@0 26 try {
michael@0 27 eval('(function ([a, b, arguments, d], [e, f, arguments]) {return arguments();})');
michael@0 28 } catch (exc) {
michael@0 29 actual = exc.name;
michael@0 30 }
michael@0 31 reportCompare("SyntaxError", actual, "part 4");
michael@0 32
michael@0 33 // The original test case from bug 509354. Don't crash.
michael@0 34 try {
michael@0 35 eval('print(function([arguments,arguments,arguments,arguments,arguments,' +
michael@0 36 'arguments,arguments,arguments,arguments,arguments,arguments,' +
michael@0 37 'arguments,arguments,arguments,arguments,arguments]){})');
michael@0 38 } catch (exc) {
michael@0 39 }
michael@0 40 reportCompare("no crash", "no crash", "part 5");
michael@0 41

mercurial