Debian Codegraph @

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

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