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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strict-mode.js
diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js
index e8f6e1cb2f7aef512237230d1933eb3aa61a688f..1f7666fcabcbfeb63ae96b21546a86ac91a07688 100644
--- a/test/mjsunit/strict-mode.js
+++ b/test/mjsunit/strict-mode.js
@@ -1081,3 +1081,54 @@ function CheckPillDescriptor(func, name) {
CheckPillDescriptor(args, "caller");
CheckPillDescriptor(args, "callee");
})();
+
+
+(function TestNonStrictFunctionCallerPillSimple() {
+ function return_my_caller() {
+ return return_my_caller.caller;
+ }
+
+ function strict() {
+ "use strict";
+ return_my_caller();
+ }
+ assertThrows(strict, TypeError);
+
+ function non_strict() {
+ return return_my_caller();
+ }
+ assertSame(non_strict(), non_strict);
+})();
+
+
+(function TestNonStrictFunctionCallerPill() {
+ function strict(n) {
+ "use strict";
+ non_strict(n);
+ }
+
+ function recurse(n, then) {
+ if (n > 0) {
+ recurse(n - 1);
+ } else {
+ return then();
+ }
+ }
+
+ function non_strict(n) {
+ recurse(n, function() { non_strict.caller; });
+ }
+
+ function test(n) {
+ try {
+ recurse(n, function() { strict(n); });
+ } catch(e) {
+ return e instanceof TypeError;
+ }
+ return false;
+ }
+
+ for (var i = 0; i < 10; i ++) {
+ assertEquals(test(i), true);
+ }
+})();
« 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