1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/arguments/rest-disallow-arguments.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +load(libdir + "asserts.js"); 1.5 +var ieval = eval; 1.6 + 1.7 +// Now for a tour of the various ways you can access arguments. 1.8 +assertThrowsInstanceOf(function () { 1.9 + ieval("function x(...rest) { arguments; }"); 1.10 +}, SyntaxError) 1.11 +assertThrowsInstanceOf(function () { 1.12 + Function("...rest", "arguments;"); 1.13 +}, SyntaxError); 1.14 +assertThrowsInstanceOf(function (...rest) { 1.15 + eval("arguments;"); 1.16 +}, SyntaxError); 1.17 +assertThrowsInstanceOf(function (...rest) { 1.18 + eval("arguments = 42;"); 1.19 +}, SyntaxError); 1.20 + 1.21 +function g(...rest) { 1.22 + assertThrowsInstanceOf(h, Error); 1.23 +} 1.24 +function h() { 1.25 + g.arguments; 1.26 +} 1.27 +g(); 1.28 + 1.29 +// eval() is evil, but you can still use it with rest parameters! 1.30 +function still_use_eval(...rest) { 1.31 + eval("x = 4"); 1.32 +} 1.33 +still_use_eval(); 1.34 \ No newline at end of file