1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/arguments/defaults-strict-mode.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +load(libdir + "asserts.js"); 1.5 + 1.6 +function f1(f=(function () { return typeof this !== "object"; })) { "use strict"; return f; } 1.7 +assertEq(f1()(), true); 1.8 +function f2(f=(function () { "use strict"; return (function () { return typeof this !== "object"; }) })) { assertEq(typeof this, "object"); return f; } 1.9 +assertEq(f2()()(), true); 1.10 +function f3(f=(function () { return (function () { return typeof this !== "object"; }) })) { "use strict"; return f; } 1.11 +assertEq(f3()()(), true); 1.12 +// These should be okay. 1.13 +function f4(f=(function () { with (Object) {} }), g=(function () { "use strict"; })) {} 1.14 +function f5(g=(function () { "use strict"; }), f=(function () { with (Object) {} })) {} 1.15 +function f6(f=(function () { return (x for (y in (function g() {}))); })) {} 1.16 + 1.17 +assertThrowsInstanceOf(function () { 1.18 + eval("function f(a=delete x) { 'use strict'; }"); 1.19 +}, SyntaxError); 1.20 +assertThrowsInstanceOf(function () { 1.21 + Math.sin(4); 1.22 + eval("function f(a='\\251') { 'use strict'; }"); 1.23 +}, SyntaxError); 1.24 +assertThrowsInstanceOf(function () { 1.25 + eval("function f(a='\\251', b=delete x) { 'use strict'; }"); 1.26 +}, SyntaxError); 1.27 +assertThrowsInstanceOf(function () { 1.28 + eval("function f(a=delete x, b='\\251') { 'use strict'; }"); 1.29 +}, SyntaxError); 1.30 +assertThrowsInstanceOf(function () { 1.31 + eval("function f(a=(function () { '\\251'; })) { 'use strict'; }"); 1.32 +}, SyntaxError); 1.33 +assertThrowsInstanceOf(function () { 1.34 + eval("function f(a=(function () { with (Object) {} })) { 'use strict'; }"); 1.35 +}, SyntaxError); 1.36 +assertThrowsInstanceOf(function () { 1.37 + eval("function f(a=(function (b, b) {})) { 'use strict'; }"); 1.38 +}, SyntaxError);