defaults-strict-mode.js (1546B)
1 load(libdir + "asserts.js"); 2 3 eval(`"use strict"; 4 function f1(f=(function () { return typeof this !== "object"; })) { return f; } 5 assertEq(f1()(), true); 6 `); 7 8 function f2(f=(function () { "use strict"; return (function () { return typeof this !== "object"; }) })) { assertEq(typeof this, "object"); return f; } 9 assertEq(f2()()(), true); 10 11 eval(`"use strict"; 12 function f3(f=(function () { return (function () { return typeof this !== "object"; }) })) { return f; } 13 assertEq(f3()()(), true); 14 `); 15 16 // These should be okay. 17 function f4(f=(function () { with (Object) {} }), g=(function () { "use strict"; })) {} 18 function f5(g=(function () { "use strict"; }), f=(function () { with (Object) {} })) {} 19 20 assertThrowsInstanceOf(function () { 21 eval("'use strict'; function f(a=delete x) { }"); 22 }, SyntaxError); 23 assertThrowsInstanceOf(function () { 24 Math.sin(4); 25 eval("'use strict'; function f(a='\\251') { }"); 26 }, SyntaxError); 27 assertThrowsInstanceOf(function () { 28 eval("'use strict'; function f(a='\\251', b=delete x) { }"); 29 }, SyntaxError); 30 assertThrowsInstanceOf(function () { 31 eval("'use strict'; function f(a=delete x, b='\\251') { }"); 32 }, SyntaxError); 33 assertThrowsInstanceOf(function () { 34 eval("'use strict'; function f(a=(function () { '\\251'; })) { }"); 35 }, SyntaxError); 36 assertThrowsInstanceOf(function () { 37 eval("'use strict'; function f(a=(function () { with (Object) {} })) { }"); 38 }, SyntaxError); 39 assertThrowsInstanceOf(function () { 40 eval("'use strict'; function f(a=(function (b, b) {})) { }"); 41 }, SyntaxError);