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 (function UseStrictNonDirective() {
89 // Function named 'eval'.
90 CheckStrictMode("function eval() {}", SyntaxError);
92 // Function named 'arguments'.
93 CheckStrictMode("function arguments() {}", SyntaxError);
95 // Function parameter named 'eval'.
96 CheckStrictMode("function foo(a, b, eval, c, d) {}", SyntaxError);
98 // Function parameter named 'arguments'.
99 CheckStrictMode("function foo(a, b, arguments, c, d) {}", SyntaxError);
107 // Duplicate function parameter name.
108 CheckStrictMode("function foo(a, b, c, d, b) {}", SyntaxError);
110 // Function constructor: eval parameter name.
113 // Function constructor: arguments parameter name.
116 // Function constructor: duplicate parameter name.
132 // Strict mode applies to the function in which the directive is used..
134 function foo(eval) {\
139 (function NotStrict(eval) {
140 function Strict() {
150 CheckStrictMode("function octal() { return 012; }");
151 CheckStrictMode("function octal() { return '\\032'; }");
153 (function ValidEscape() {
161 function strict() {\
178 (function StrictModeNonDuplicate() {
221 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError);
222 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError);
223 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError);
224 CheckStrictMode("function strict() { print(arguments = undefined); }",
226 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError);
227 CheckStrictMode("function strict() { var x = arguments = undefined; }",
231 CheckStrictMode("function strict() { eval *= undefined; }", SyntaxError);
232 CheckStrictMode("function strict() { arguments /= undefined; }", SyntaxError);
233 CheckStrictMode("function strict() { print(eval %= undefined); }", SyntaxError);
234 CheckStrictMode("function strict() { print(arguments %= undefined); }",
236 CheckStrictMode("function strict() { var x = eval += undefined; }",
238 CheckStrictMode("function strict() { var x = arguments -= undefined; }",
240 CheckStrictMode("function strict() { eval <<= undefined; }", SyntaxError);
241 CheckStrictMode("function strict() { arguments >>= undefined; }", SyntaxError);
242 CheckStrictMode("function strict() { print(eval >>>= undefined); }",
244 CheckStrictMode("function strict() { print(arguments &= undefined); }",
246 CheckStrictMode("function strict() { var x = eval ^= undefined; }",
248 CheckStrictMode("function strict() { var x = arguments |= undefined; }",
252 CheckStrictMode("function strict() { eval++; }", SyntaxError);
253 CheckStrictMode("function strict() { arguments++; }", SyntaxError);
254 CheckStrictMode("function strict() { print(eval++); }", SyntaxError);
255 CheckStrictMode("function strict() { print(arguments++); }", SyntaxError);
256 CheckStrictMode("function strict() { var x = eval++; }", SyntaxError);
257 CheckStrictMode("function strict() { var x = arguments++; }", SyntaxError);
260 CheckStrictMode("function strict() { eval--; }", SyntaxError);
261 CheckStrictMode("function strict() { arguments--; }", SyntaxError);
262 CheckStrictMode("function strict() { print(eval--); }", SyntaxError);
263 CheckStrictMode("function strict() { print(arguments--); }", SyntaxError);
264 CheckStrictMode("function strict() { var x = eval--; }", SyntaxError);
265 CheckStrictMode("function strict() { var x = arguments--; }", SyntaxError);
268 CheckStrictMode("function strict() { ++eval; }", SyntaxError);
269 CheckStrictMode("function strict() { ++arguments; }", SyntaxError);
270 CheckStrictMode("function strict() { print(++eval); }", SyntaxError);
271 CheckStrictMode("function strict() { print(++arguments); }", SyntaxError);
272 CheckStrictMode("function strict() { var x = ++eval; }", SyntaxError);
273 CheckStrictMode("function strict() { var x = ++arguments; }", SyntaxError);
276 CheckStrictMode("function strict() { --eval; }", SyntaxError);
277 CheckStrictMode("function strict() { --arguments; }", SyntaxError);
278 CheckStrictMode("function strict() { print(--eval); }", SyntaxError);
279 CheckStrictMode("function strict() { print(--arguments); }", SyntaxError);
280 CheckStrictMode("function strict() { var x = --eval; }", SyntaxError);
281 CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError);
286 CheckStrictMode("function strict() { const x = 0; }", SyntaxError);
289 CheckStrictMode("if (true) { function invalid() {} }", SyntaxError);
290 CheckStrictMode("for (;false;) { function invalid() {} }", SyntaxError);
291 CheckStrictMode("{ function invalid() {} }", SyntaxError);
292 CheckStrictMode("try { function invalid() {} } catch(e) {}", SyntaxError);
293 CheckStrictMode("try { } catch(e) { function invalid() {} }", SyntaxError);
294 CheckStrictMode("function outer() {{ function invalid() {} }}", SyntaxError);
298 CheckStrictMode("function strict() { delete unqualified; }", SyntaxError);
299 CheckStrictMode("function function_name() { delete function_name; }",
301 CheckStrictMode("function strict(parameter) { delete parameter; }",
303 CheckStrictMode("function strict() { var variable; delete variable; }",
307 (function TestStrictDelete() {
310 function strict_delete() { delete this; }
315 (function StrictModeUnaryOperators() {
340 function testFutureReservedWord(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 + ") 'use strict'; {}", SyntaxError);
368 assertThrows("function foo (" + word + ", " + word + ") { 'use strict'; }",
370 assertThrows("function foo (a, " + word + ") { 'use strict'; }", SyntaxError);
371 assertThrows("function foo (" + word + ", a) { 'use strict'; }", SyntaxError);
372 assertThrows("function foo (a, " + word + ", b) { 'use strict'; }",
374 assertThrows("var foo = function (" + word + ") { 'use strict'; }",
390 function testAssignToUndefined(test, should_throw) {
401 function repeat(n, f) {
405 function assignToUndefined() {
426 repeat(10, function() { testAssignToUndefined(assignToUndefined, true); });
428 repeat(10, function() { testAssignToUndefined(assignToUndefined, false); });
430 repeat(10, function() { testAssignToUndefined(assignToUndefined, true); });
432 repeat(10, function() { testAssignToUndefined(assignToUndefined, false); });
434 function assignToUndefinedWithEval() {
456 repeat(10, function() {
460 repeat(10, function() {
464 repeat(10, function() {
468 repeat(10, function() {
474 (function testDeleteNonConfigurable() {
475 function delete_property(o) {
479 function delete_element(o, i) {
491 assertThrows(function() { delete_property(object); }, TypeError);
493 assertThrows(function() { delete_element(object, "1"); }, TypeError);
494 assertThrows(function() { delete_element(object, 1); }, TypeError);
496 assertThrows(function() { delete_element(object, "7"); }, TypeError);
497 assertThrows(function() { delete_element(object, 7); }, TypeError);
499 assertThrows(function() { delete_element(object, "3.14"); }, TypeError);
500 assertThrows(function() { delete_element(object, 3.14); }, TypeError);
504 // Not transforming this in Function.call and Function.apply.
505 (function testThisTransformCallApply() {
506 function non_strict() {
509 function strict() {
514 var global_object = (function() { return this; })();
546 (function testThisTransform() {
548 function strict() {
552 function nonstrict() {
566 function install(t) {
572 { get: function() { return strict; },
575 { get: function() { return nonstrict; },
578 { get: function() { return strict; },
581 { get: function() { return nonstrict; },
585 function cleanup(t) {
601 function callStrict(o) {
604 function callNonStrict(o) {
607 function callKeyedStrict(o) {
610 function callKeyedNonStrict(o) {
613 function callIndexedStrict(o) {
616 function callIndexedNonStrict(o) {
619 function callStrictGet(o) {
622 function callNonStrictGet(o) {
625 function callKeyedStrictGet(o) {
628 function callKeyedNonStrictGet(o) {
631 function callIndexedStrictGet(o) {
634 function callIndexedNonStrictGet(o) {
762 (function ObjectEnvironment() {
766 function () {
768 (function() {
778 (function TestSetPropertyWithoutSetter() {
781 function broken() {
789 (function TestSetPropertyNonConfigurable() {
793 function strict(o) {
798 assertThrows(function() { strict(frozen); }, TypeError);
799 assertThrows(function() { strict(sealed); }, TypeError);
803 (function TestAssignmentToReadOnlyProperty() {
809 assertThrows(function() { o.property = "new value"; }, TypeError);
810 assertThrows(function() { o.property += 10; }, TypeError);
811 assertThrows(function() { o.property -= 10; }, TypeError);
812 assertThrows(function() { o.property *= 10; }, TypeError);
813 assertThrows(function() { o.property /= 10; }, TypeError);
814 assertThrows(function() { o.property++; }, TypeError);
815 assertThrows(function() { o.property--; }, TypeError);
816 assertThrows(function() { ++o.property; }, TypeError);
817 assertThrows(function() { --o.property; }, TypeError);
820 assertThrows(function() { o[name] = "new value"; }, TypeError);
821 assertThrows(function() { o[name] += 10; }, TypeError);
822 assertThrows(function() { o[name] -= 10; }, TypeError);
823 assertThrows(function() { o[name] *= 10; }, TypeError);
824 assertThrows(function() { o[name] /= 10; }, TypeError);
825 assertThrows(function() { o[name]++; }, TypeError);
826 assertThrows(function() { o[name]--; }, TypeError);
827 assertThrows(function() { ++o[name]; }, TypeError);
828 assertThrows(function() { --o[name]; }, TypeError);
834 (function TestAssignmentToReadOnlyLoop() {
839 function strict(o, name) {
856 (function testKeyedStoreICStrict() {
859 function test(o, i, v) {
877 (function TestSetElementWithoutSetter() {
881 Object.defineProperty(o, 0, { get : function() { } });
888 assertThrows(function() { o[zero_smi] = "new value"; }, TypeError);
889 assertThrows(function() { o[zero_number] = "new value"; }, TypeError);
890 assertThrows(function() { o[zero_symbol] = "new value"; }, TypeError);
891 assertThrows(function() { o[zero_string] = "new value"; }, TypeError);
895 (function TestSetElementNonConfigurable() {
904 assertThrows(function() { frozen[zero_number] = "value"; }, TypeError);
905 assertThrows(function() { sealed[zero_number] = "value"; }, TypeError);
906 assertThrows(function() { frozen[zero_symbol] = "value"; }, TypeError);
907 assertThrows(function() { sealed[zero_symbol] = "value"; }, TypeError);
908 assertThrows(function() { frozen[zero_string] = "value"; }, TypeError);
909 assertThrows(function() { sealed[zero_string] = "value"; }, TypeError);
913 (function TestAssignmentToReadOnlyElement() {
925 assertThrows(function() { o[seven_smi] = "value"; }, TypeError);
926 assertThrows(function() { o[seven_smi] += 10; }, TypeError);
927 assertThrows(function() { o[seven_smi] -= 10; }, TypeError);
928 assertThrows(function() { o[seven_smi] *= 10; }, TypeError);
929 assertThrows(function() { o[seven_smi] /= 10; }, TypeError);
930 assertThrows(function() { o[seven_smi]++; }, TypeError);
931 assertThrows(function() { o[seven_smi]--; }, TypeError);
932 assertThrows(function() { ++o[seven_smi]; }, TypeError);
933 assertThrows(function() { --o[seven_smi]; }, TypeError);
935 assertThrows(function() { o[seven_number] = "value"; }, TypeError);
936 assertThrows(function() { o[seven_number] += 10; }, TypeError);
937 assertThrows(function() { o[seven_number] -= 10; }, TypeError);
938 assertThrows(function() { o[seven_number] *= 10; }, TypeError);
939 assertThrows(function() { o[seven_number] /= 10; }, TypeError);
940 assertThrows(function() { o[seven_number]++; }, TypeError);
941 assertThrows(function() { o[seven_number]--; }, TypeError);
942 assertThrows(function() { ++o[seven_number]; }, TypeError);
943 assertThrows(function() { --o[seven_number]; }, TypeError);
945 assertThrows(function() { o[seven_symbol] = "value"; }, TypeError);
946 assertThrows(function() { o[seven_symbol] += 10; }, TypeError);
947 assertThrows(function() { o[seven_symbol] -= 10; }, TypeError);
948 assertThrows(function() { o[seven_symbol] *= 10; }, TypeError);
949 assertThrows(function() { o[seven_symbol] /= 10; }, TypeError);
950 assertThrows(function() { o[seven_symbol]++; }, TypeError);
951 assertThrows(function() { o[seven_symbol]--; }, TypeError);
952 assertThrows(function() { ++o[seven_symbol]; }, TypeError);
953 assertThrows(function() { --o[seven_symbol]; }, TypeError);
955 assertThrows(function() { o[seven_string] = "value"; }, TypeError);
956 assertThrows(function() { o[seven_string] += 10; }, TypeError);
957 assertThrows(function() { o[seven_string] -= 10; }, TypeError);
958 assertThrows(function() { o[seven_string] *= 10; }, TypeError);
959 assertThrows(function() { o[seven_string] /= 10; }, TypeError);
960 assertThrows(function() { o[seven_string]++; }, TypeError);
961 assertThrows(function() { o[seven_string]--; }, TypeError);
962 assertThrows(function() { ++o[seven_string]; }, TypeError);
963 assertThrows(function() { --o[seven_string]; }, TypeError);
971 (function TestAssignmentToReadOnlyLoop() {
983 assertThrows(function() { o[seven_smi] = "value" }, TypeError);
984 assertThrows(function() { o[seven_number] = "value" }, TypeError);
985 assertThrows(function() { o[seven_symbol] = "value" }, TypeError);
986 assertThrows(function() { o[seven_string] = "value" }, TypeError);
993 (function TestAssignmentToStringLength() {
1000 assertThrows(function() { str_val.length = 1; }, TypeError);
1001 assertThrows(function() { str_obj.length = 1; }, TypeError);
1002 assertThrows(function() { str_cat.length = 1; }, TypeError);
1006 (function TestArgumentsAliasing() {
1007 function strict(a, b) {
1014 function nonstrict(a, b) {
1025 function CheckPillDescriptor(func, name) {
1027 function CheckPill(pill) {
1028 assertEquals("function", typeof pill);
1029 assertInstanceof(pill, Function);
1032 assertThrows(function() { 'use strict'; pill.property = "value"; },
1035 assertEquals(pill.prototype, (function(){}).prototype);
1050 (function TestStrictFunctionPills() {
1051 function strict() {
1054 assertThrows(function() { strict.caller; }, TypeError);
1055 assertThrows(function() { strict.arguments; }, TypeError);
1057 var another = new Function("'use strict'");
1058 assertThrows(function() { another.caller; }, TypeError);
1059 assertThrows(function() { another.arguments; }, TypeError);
1061 var third = (function() { "use strict"; return function() {}; })();
1062 assertThrows(function() { third.caller; }, TypeError);
1063 assertThrows(function() { third.arguments; }, TypeError);
1074 (function TestStrictFunctionWritablePrototype() {
1076 function TheClass() {
1078 assertThrows(function() { TheClass.caller; }, TypeError);
1079 assertThrows(function() { TheClass.arguments; }, TypeError);
1083 func: function() { return "func_value"; },
1095 (function TestStrictArgumentPills() {
1096 function strict() {
1112 function outer() {
1114 function inner() {
1133 (function TestNonStrictFunctionCallerPillSimple() {
1134 function return_my_caller() {
1138 function strict() {
1144 function non_strict() {
1151 (function TestNonStrictFunctionCallerPill() {
1152 function strict(n) {
1157 function recurse(n, then) {
1165 function non_strict(n) {
1166 recurse(n, function() { non_strict.caller; });
1169 function test(n) {
1171 recurse(n, function() { strict(n); });