Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: test/mjsunit/strict-mode.js

Issue 6713059: Function.caller when caller is a strict function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 CheckPillDescriptor(args, "caller"); 1074 CheckPillDescriptor(args, "caller");
1075 CheckPillDescriptor(args, "callee"); 1075 CheckPillDescriptor(args, "callee");
1076 1076
1077 args = outer()(17, "value", strict); 1077 args = outer()(17, "value", strict);
1078 assertEquals(17, args[0]) 1078 assertEquals(17, args[0])
1079 assertEquals("value", args[1]) 1079 assertEquals("value", args[1])
1080 assertEquals(strict, args[2]); 1080 assertEquals(strict, args[2]);
1081 CheckPillDescriptor(args, "caller"); 1081 CheckPillDescriptor(args, "caller");
1082 CheckPillDescriptor(args, "callee"); 1082 CheckPillDescriptor(args, "callee");
1083 })(); 1083 })();
1084
1085
1086 (function TestNonStrictFunctionCallerPillSimple() {
1087 function return_my_caller() {
1088 return return_my_caller.caller;
1089 }
1090
1091 function strict() {
1092 "use strict";
1093 return_my_caller();
1094 }
1095 assertThrows(strict, TypeError);
1096
1097 function non_strict() {
1098 return return_my_caller();
1099 }
1100 assertSame(non_strict(), non_strict);
1101 })();
1102
1103
1104 (function TestNonStrictFunctionCallerPill() {
1105 function strict(n) {
1106 "use strict";
1107 non_strict(n);
1108 }
1109
1110 function recurse(n, then) {
1111 if (n > 0) {
1112 recurse(n - 1);
1113 } else {
1114 return then();
1115 }
1116 }
1117
1118 function non_strict(n) {
1119 recurse(n, function() { non_strict.caller; });
1120 }
1121
1122 function test(n) {
1123 try {
1124 recurse(n, function() { strict(n); });
1125 } catch(e) {
1126 return e instanceof TypeError;
1127 }
1128 return false;
1129 }
1130
1131 for (var i = 0; i < 10; i ++) {
1132 assertEquals(test(i), true);
1133 }
1134 })();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698