Home | History | Annotate | Download | only in mjsunit

Lines Matching refs:function

28 function CheckStrictMode(code, exception) {
33 function outer() {\
34 function inner() {\n"
39 function outer() {\
41 function inner() {\n"
47 function CheckFunctionConstructorStrictMode() {
52 // Create non-strict function. No exception.
54 assertDoesNotThrow(function() {
55 Function.apply(this, args);
57 // Create strict mode function. Exception expected.
59 assertThrows(function() {
60 Function.apply(this, args);
65 (function UseStrictEscape() {
71 assertThrows("function foo (x) 'use strict'; {}", SyntaxError);
74 (function UseStrictNonDirective() {
92 // Function named 'eval'.
93 CheckStrictMode("function eval() {}", SyntaxError);
95 // Function named 'arguments'.
96 CheckStrictMode("function arguments() {}", SyntaxError);
98 // Function parameter named 'eval'.
99 CheckStrictMode("function foo(a, b, eval, c, d) {}", SyntaxError);
101 // Function parameter named 'arguments'.
102 CheckStrictMode("function foo(a, b, arguments, c, d) {}", SyntaxError);
110 // Duplicate function parameter name.
111 CheckStrictMode("function foo(a, b, c, d, b) {}", SyntaxError);
113 // Function constructor: eval parameter name.
116 // Function constructor: arguments parameter name.
119 // Function constructor: duplicate parameter name.
135 // Strict mode applies to the function in which the directive is used..
137 function foo(eval) {\
142 (function NotStrict(eval) {
143 function Strict() {
153 CheckStrictMode("function octal() { return 012; }");
154 CheckStrictMode("function octal() { return '\\032'; }");
156 (function ValidEscape() {
164 function strict() {\
181 (function StrictModeNonDuplicate() {
224 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError);
225 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError);
226 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError);
227 CheckStrictMode("function strict() { print(arguments = undefined); }",
229 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError);
230 CheckStrictMode("function strict() { var x = arguments = undefined; }",
234 CheckStrictMode("function strict() { eval *= undefined; }", SyntaxError);
235 CheckStrictMode("function strict() { arguments /= undefined; }", SyntaxError);
236 CheckStrictMode("function strict() { print(eval %= undefined); }", SyntaxError);
237 CheckStrictMode("function strict() { print(arguments %= undefined); }",
239 CheckStrictMode("function strict() { var x = eval += undefined; }",
241 CheckStrictMode("function strict() { var x = arguments -= undefined; }",
243 CheckStrictMode("function strict() { eval <<= undefined; }", SyntaxError);
244 CheckStrictMode("function strict() { arguments >>= undefined; }", SyntaxError);
245 CheckStrictMode("function strict() { print(eval >>>= undefined); }",
247 CheckStrictMode("function strict() { print(arguments &= undefined); }",
249 CheckStrictMode("function strict() { var x = eval ^= undefined; }",
251 CheckStrictMode("function strict() { var x = arguments |= undefined; }",
255 CheckStrictMode("function strict() { eval++; }", SyntaxError);
256 CheckStrictMode("function strict() { arguments++; }", SyntaxError);
257 CheckStrictMode("function strict() { print(eval++); }", SyntaxError);
258 CheckStrictMode("function strict() { print(arguments++); }", SyntaxError);
259 CheckStrictMode("function strict() { var x = eval++; }", SyntaxError);
260 CheckStrictMode("function strict() { var x = arguments++; }", SyntaxError);
263 CheckStrictMode("function strict() { eval--; }", SyntaxError);
264 CheckStrictMode("function strict() { arguments--; }", SyntaxError);
265 CheckStrictMode("function strict() { print(eval--); }", SyntaxError);
266 CheckStrictMode("function strict() { print(arguments--); }", SyntaxError);
267 CheckStrictMode("function strict() { var x = eval--; }", SyntaxError);
268 CheckStrictMode("function strict() { var x = arguments--; }", SyntaxError);
271 CheckStrictMode("function strict() { ++eval; }", SyntaxError);
272 CheckStrictMode("function strict() { ++arguments; }", SyntaxError);
273 CheckStrictMode("function strict() { print(++eval); }", SyntaxError);
274 CheckStrictMode("function strict() { print(++arguments); }", SyntaxError);
275 CheckStrictMode("function strict() { var x = ++eval; }", SyntaxError);
276 CheckStrictMode("function strict() { var x = ++arguments; }", SyntaxError);
279 CheckStrictMode("function strict() { --eval; }", SyntaxError);
280 CheckStrictMode("function strict() { --arguments; }", SyntaxError);
281 CheckStrictMode("function strict() { print(--eval); }", SyntaxError);
282 CheckStrictMode("function strict() { print(--arguments); }", SyntaxError);
283 CheckStrictMode("function strict() { var x = --eval; }", SyntaxError);
284 CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError);
289 CheckStrictMode("function strict() { const x = 0; }", SyntaxError);
292 CheckStrictMode("if (true) { function invalid() {} }", SyntaxError);
293 CheckStrictMode("for (;false;) { function invalid() {} }", SyntaxError);
294 CheckStrictMode("{ function invalid() {} }", SyntaxError);
295 CheckStrictMode("try { function invalid() {} } catch(e) {}", SyntaxError);
296 CheckStrictMode("try { } catch(e) { function invalid() {} }", SyntaxError);
297 CheckStrictMode("function outer() {{ function invalid() {} }}", SyntaxError);
301 CheckStrictMode("function strict() { delete unqualified; }", SyntaxError);
302 CheckStrictMode("function function_name() { delete function_name; }",
304 CheckStrictMode("function strict(parameter) { delete parameter; }",
306 CheckStrictMode("function strict() { var variable; delete variable; }",
310 (function TestStrictDelete() {
313 function strict_delete() { delete this; }
318 (function StrictModeUnaryOperators() {
337 function testFutureStrictReservedWord(word) {
356 // Function names and arguments, strict and non-strict contexts
357 CheckStrictMode("function " + word + " () {}", SyntaxError);
358 CheckStrictMode("function foo (" + word + ") {}", SyntaxError);
359 CheckStrictMode("function foo (" + word + ", " + word + ") {}", SyntaxError);
360 CheckStrictMode("function foo (a, " + word + ") {}", SyntaxError);
361 CheckStrictMode("function foo (" + word + ", a) {}", SyntaxError);
362 CheckStrictMode("function foo (a, " + word + ", b) {}", SyntaxError);
363 CheckStrictMode("var foo = function (" + word + ") {}", SyntaxError);
365 // Function names and arguments when the body is strict
366 assertThrows("function " + word + " () { 'use strict'; }", SyntaxError);
367 assertThrows("function foo (" + word + ", " + word + ") { 'use strict'; }",
369 assertThrows("function foo (a, " + word + ") { 'use strict'; }", SyntaxError);
370 assertThrows("function foo (" + word + ", a) { 'use strict'; }", SyntaxError);
371 assertThrows("function foo (a, " + word + ", b) { 'use strict'; }",
373 assertThrows("var foo = function (" + word + ") { 'use strict'; }",
386 function testAssignToUndefined(test, should_throw) {
397 function repeat(n, f) {
401 function assignToUndefined() {
422 repeat(10, function() { testAssignToUndefined(assignToUndefined, true); });
424 repeat(10, function() { testAssignToUndefined(assignToUndefined, false); });
426 repeat(10, function() { testAssignToUndefined(assignToUndefined, true); });
428 repeat(10, function() { testAssignToUndefined(assignToUndefined, false); });
430 function assignToUndefinedWithEval() {
452 repeat(10, function() {
456 repeat(10, function() {
460 repeat(10, function() {
464 repeat(10, function() {
470 (function testDeleteNonConfigurable() {
471 function delete_property(o) {
475 function delete_element(o, i) {
487 assertThrows(function() { delete_property(object); }, TypeError);
489 assertThrows(function() { delete_element(object, "1"); }, TypeError);
490 assertThrows(function() { delete_element(object, 1); }, TypeError);
492 assertThrows(function() { delete_element(object, "7"); }, TypeError);
493 assertThrows(function() { delete_element(object, 7); }, TypeError);
495 assertThrows(function() { delete_element(object, "3.14"); }, TypeError);
496 assertThrows(function() { delete_element(object, 3.14); }, TypeError);
500 // Not transforming this in Function.call and Function.apply.
501 (function testThisTransformCallApply() {
502 function non_strict() {
505 function strict() {
510 var global_object = (function() { return this; })();
542 (function testThisTransform() {
544 function strict() {
548 function nonstrict() {
562 function install(t) {
568 { get: function() { return strict; },
571 { get: function() { return nonstrict; },
574 { get: function() { return strict; },
577 { get: function() { return nonstrict; },
581 function cleanup(t) {
597 function callStrict(o) {
600 function callNonStrict(o) {
603 function callKeyedStrict(o) {
606 function callKeyedNonStrict(o) {
609 function callIndexedStrict(o) {
612 function callIndexedNonStrict(o) {
615 function callStrictGet(o) {
618 function callNonStrictGet(o) {
621 function callKeyedStrictGet(o) {
624 function callKeyedNonStrictGet(o) {
627 function callIndexedStrictGet(o) {
630 function callIndexedNonStrictGet(o) {
758 (function ObjectEnvironment() {
762 function () {
764 (function() {
774 (function TestSetPropertyWithoutSetter() {
777 function broken() {
785 (function TestSetPropertyNonConfigurable() {
789 function strict(o) {
794 assertThrows(function() { strict(frozen); }, TypeError);
795 assertThrows(function() { strict(sealed); }, TypeError);
799 (function TestAssignmentToReadOnlyProperty() {
805 assertThrows(function() { o.property = "new value"; }, TypeError);
806 assertThrows(function() { o.property += 10; }, TypeError);
807 assertThrows(function() { o.property -= 10; }, TypeError);
808 assertThrows(function() { o.property *= 10; }, TypeError);
809 assertThrows(function() { o.property /= 10; }, TypeError);
810 assertThrows(function() { o.property++; }, TypeError);
811 assertThrows(function() { o.property--; }, TypeError);
812 assertThrows(function() { ++o.property; }, TypeError);
813 assertThrows(function() { --o.property; }, TypeError);
816 assertThrows(function() { o[name] = "new value"; }, TypeError);
817 assertThrows(function() { o[name] += 10; }, TypeError);
818 assertThrows(function() { o[name] -= 10; }, TypeError);
819 assertThrows(function() { o[name] *= 10; }, TypeError);
820 assertThrows(function() { o[name] /= 10; }, TypeError);
821 assertThrows(function() { o[name]++; }, TypeError);
822 assertThrows(function() { o[name]--; }, TypeError);
823 assertThrows(function() { ++o[name]; }, TypeError);
824 assertThrows(function() { --o[name]; }, TypeError);
830 (function TestAssignmentToReadOnlyLoop() {
835 function strict(o, name) {
854 (function testKeyedStoreICStrict() {
857 function test(o, i, v) {
875 (function TestSetElementWithoutSetter() {
879 function() { } });
886 assertThrows(function() { o[zero_smi] = "new value"; }, TypeError);
887 assertThrows(function() { o[zero_number] = "new value"; }, TypeError);
888 assertThrows(function() { o[zero_symbol] = "new value"; }, TypeError);
889 assertThrows(function() { o[zero_string] = "new value"; }, TypeError);
893 (function TestSetElementNonConfigurable() {
902 assertThrows(function() { frozen[zero_number] = "value"; }, TypeError);
903 assertThrows(function() { sealed[zero_number] = "value"; }, TypeError);
904 assertThrows(function() { frozen[zero_symbol] = "value"; }, TypeError);
905 assertThrows(function() { sealed[zero_symbol] = "value"; }, TypeError);
906 assertThrows(function() { frozen[zero_string] = "value"; }, TypeError);
907 assertThrows(function() { sealed[zero_string] = "value"; }, TypeError);
911 (function TestAssignmentToReadOnlyElement() {
923 assertThrows(function() { o[seven_smi] = "value"; }, TypeError);
924 assertThrows(function() { o[seven_smi] += 10; }, TypeError);
925 assertThrows(function() { o[seven_smi] -= 10; }, TypeError);
926 assertThrows(function() { o[seven_smi] *= 10; }, TypeError);
927 assertThrows(function() { o[seven_smi] /= 10; }, TypeError);
928 assertThrows(function() { o[seven_smi]++; }, TypeError);
929 assertThrows(function() { o[seven_smi]--; }, TypeError);
930 assertThrows(function() { ++o[seven_smi]; }, TypeError);
931 assertThrows(function() { --o[seven_smi]; }, TypeError);
933 assertThrows(function() { o[seven_number] = "value"; }, TypeError);
934 assertThrows(function() { o[seven_number] += 10; }, TypeError);
935 assertThrows(function() { o[seven_number] -= 10; }, TypeError);
936 assertThrows(function() { o[seven_number] *= 10; }, TypeError);
937 assertThrows(function() { o[seven_number] /= 10; }, TypeError);
938 assertThrows(function() { o[seven_number]++; }, TypeError);
939 assertThrows(function() { o[seven_number]--; }, TypeError);
940 assertThrows(function() { ++o[seven_number]; }, TypeError);
941 assertThrows(function() { --o[seven_number]; }, TypeError);
943 assertThrows(function() { o[seven_symbol] = "value"; }, TypeError);
944 assertThrows(function() { o[seven_symbol] += 10; }, TypeError);
945 assertThrows(function() { o[seven_symbol] -= 10; }, TypeError);
946 assertThrows(function() { o[seven_symbol] *= 10; }, TypeError);
947 assertThrows(function() { o[seven_symbol] /= 10; }, TypeError);
948 assertThrows(function() { o[seven_symbol]++; }, TypeError);
949 assertThrows(function() { o[seven_symbol]--; }, TypeError);
950 assertThrows(function() { ++o[seven_symbol]; }, TypeError);
951 assertThrows(function() { --o[seven_symbol]; }, TypeError);
953 assertThrows(function() { o[seven_string] = "value"; }, TypeError);
954 assertThrows(function() { o[seven_string] += 10; }, TypeError);
955 assertThrows(function() { o[seven_string] -= 10; }, TypeError);
956 assertThrows(function() { o[seven_string] *= 10; }, TypeError);
957 assertThrows(function() { o[seven_string] /= 10; }, TypeError);
958 assertThrows(function() { o[seven_string]++; }, TypeError);
959 assertThrows(function() { o[seven_string]--; }, TypeError);
960 assertThrows(function() { ++o[seven_string]; }, TypeError);
961 assertThrows(function() { --o[seven_string]; }, TypeError);
969 (function TestAssignmentToReadOnlyLoop() {
981 assertThrows(function() { o[seven_smi] = "value" }, TypeError);
982 assertThrows(function() { o[seven_number] = "value" }, TypeError);
983 assertThrows(function() { o[seven_symbol] = "value" }, TypeError);
984 assertThrows(function() { o[seven_string] = "value" }, TypeError);
991 (function TestAssignmentToStringLength() {
998 assertThrows(function() { str_val.length = 1; }, TypeError);
999 assertThrows(function() { str_obj.length = 1; }, TypeError);
1000 assertThrows(function() { str_cat.length = 1; }, TypeError);
1004 (function TestArgumentsAliasing() {
1005 function strict(a, b) {
1012 function nonstrict(a, b) {
1023 function CheckPillDescriptor(func, name) {
1025 function CheckPill(pill) {
1026 assertEquals("function", typeof pill);
1027 assertInstanceof(pill, Function);
1030 assertThrows(function() { 'use strict'; pill.property = "value"; },
1033 assertEquals(pill.prototype, (function(){}).prototype);
1048 (function TestStrictFunctionPills() {
1049 function strict() {
1052 assertThrows(function() { strict.caller; }, TypeError);
1053 assertThrows(function() { strict.arguments; }, TypeError);
1054 assertThrows(function() { strict.caller = 42; }, TypeError);
1055 assertThrows(function() { strict.arguments = 42; }, TypeError);
1057 var another = new Function("'use strict'");
1058 assertThrows(function() { another.caller; }, TypeError);
1059 assertThrows(function() { another.arguments; }, TypeError);
1060 assertThrows(function() { another.caller = 42; }, TypeError);
1061 assertThrows(function() { another.arguments = 42; }, TypeError);
1063 var third = (function() { "use strict"; return function() {}; })();
1064 assertThrows(function() { third.caller; }, TypeError);
1065 assertThrows(function() { third.arguments; }, TypeError);
1066 assertThrows(function() { third.caller = 42; }, TypeError);
1067 assertThrows(function() { third.arguments = 42; }, TypeError);
1078 (function TestStrictFunctionWritablePrototype() {
1080 function TheClass() {
1082 assertThrows(function() { TheClass.caller; }, TypeError);
1083 assertThrows(function() { TheClass.arguments; }, TypeError);
1087 func: function() { return "func_value"; },
1099 (function TestStrictArgumentPills() {
1100 function strict() {
1116 function outer() {
1118 function inner() {
1137 (function TestNonStrictFunctionCallerPillSimple() {
1138 function return_my_caller() {
1142 function strict() {
1148 function non_strict() {
1155 (function TestNonStrictFunctionCallerPill() {
1156 function strict(n) {
1161 function recurse(n, then) {
1169 function non_strict(n) {
1170 return recurse(n, function() { return non_strict.caller; });
1173 function test(n) {
1174 return recurse(n, function() { return strict(n); });
1183 (function TestNonStrictFunctionCallerDescriptorPill() {
1184 function strict(n) {
1189 function recurse(n, then) {
1197 function non_strict(n) {
1198 return recurse(n, function() {
1203 function test(n) {
1204 return recurse(n, function() { return strict(n); });
1213 (function TestStrictModeEval() {
1216 assertThrows(function() { return eval_local; }, ReferenceError);