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

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

mercurial