michael@0: load(libdir + "asserts.js"); michael@0: michael@0: function f1(f=(function () { return typeof this !== "object"; })) { "use strict"; return f; } michael@0: assertEq(f1()(), true); michael@0: function f2(f=(function () { "use strict"; return (function () { return typeof this !== "object"; }) })) { assertEq(typeof this, "object"); return f; } michael@0: assertEq(f2()()(), true); michael@0: function f3(f=(function () { return (function () { return typeof this !== "object"; }) })) { "use strict"; return f; } michael@0: assertEq(f3()()(), true); michael@0: // These should be okay. michael@0: function f4(f=(function () { with (Object) {} }), g=(function () { "use strict"; })) {} michael@0: function f5(g=(function () { "use strict"; }), f=(function () { with (Object) {} })) {} michael@0: function f6(f=(function () { return (x for (y in (function g() {}))); })) {} michael@0: michael@0: assertThrowsInstanceOf(function () { michael@0: eval("function f(a=delete x) { 'use strict'; }"); michael@0: }, SyntaxError); michael@0: assertThrowsInstanceOf(function () { michael@0: Math.sin(4); michael@0: eval("function f(a='\\251') { 'use strict'; }"); michael@0: }, SyntaxError); michael@0: assertThrowsInstanceOf(function () { michael@0: eval("function f(a='\\251', b=delete x) { 'use strict'; }"); michael@0: }, SyntaxError); michael@0: assertThrowsInstanceOf(function () { michael@0: eval("function f(a=delete x, b='\\251') { 'use strict'; }"); michael@0: }, SyntaxError); michael@0: assertThrowsInstanceOf(function () { michael@0: eval("function f(a=(function () { '\\251'; })) { 'use strict'; }"); michael@0: }, SyntaxError); michael@0: assertThrowsInstanceOf(function () { michael@0: eval("function f(a=(function () { with (Object) {} })) { 'use strict'; }"); michael@0: }, SyntaxError); michael@0: assertThrowsInstanceOf(function () { michael@0: eval("function f(a=(function (b, b) {})) { 'use strict'; }"); michael@0: }, SyntaxError);