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

Unified Diff: test/mjsunit/eval.js

Issue 8343054: Make eval consider anything on the form eval(args...) a potential direct cal (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 9 years, 2 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 | « test/cctest/test-api.cc ('k') | test/mjsunit/regress/regress-221.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/eval.js
diff --git a/test/mjsunit/eval.js b/test/mjsunit/eval.js
index b6284ba911dece6ee77f74a8b46a81b8bfa45927..100f21653fb2943a63c88473e45de6f263d445ad 100644
--- a/test/mjsunit/eval.js
+++ b/test/mjsunit/eval.js
@@ -39,7 +39,7 @@ assertEquals(1, count);
try {
eval('hest 7 &*^*&^');
- assertTrue(false, 'Did not throw on syntax error.');
+ assertUnreachable('Did not throw on syntax error.');
} catch (e) {
assertEquals('SyntaxError', e.name);
}
@@ -108,6 +108,7 @@ foo = 0;
result =
(function() {
var foo = 2;
+ // Should be non-direct call.
return x.eval('foo');
})();
assertEquals(0, result);
@@ -115,12 +116,33 @@ assertEquals(0, result);
foo = 0;
result =
(function() {
+ var foo = 2;
+ // Should be non-direct call.
+ return (1,eval)('foo');
+ })();
+assertEquals(0, result);
+
+foo = 0;
+result =
+ (function() {
var eval = function(x) { return x; };
var foo = eval(2);
+ // Should be non-direct call.
return e('foo');
})();
assertEquals(0, result);
+foo = 0;
+result =
+ (function() {
+ var foo = 2;
+ // Should be direct call.
+ with ({ eval : e }) {
+ return eval('foo');
+ }
+ })();
+assertEquals(2, result);
+
result =
(function() {
var eval = function(x) { return 2 * x; };
@@ -135,19 +157,17 @@ result =
})();
assertEquals(this, result);
-result =
- (function() {
- var obj = { f: function(eval) { return eval("this"); } };
- return obj.f(eval);
- })();
-assertEquals(this, result);
+(function() {
+ var obj = { f: function(eval) { return eval("this"); } };
+ result = obj.f(eval);
+ assertEquals(obj, result);
+})();
-result =
- (function() {
- var obj = { f: function(eval) { arguments; return eval("this"); } };
- return obj.f(eval);
- })();
-assertEquals(this, result);
+(function() {
+ var obj = { f: function(eval) { arguments; return eval("this"); } };
+ result = obj.f(eval);
+ assertEquals(obj, result);
+})();
eval = function(x) { return 2 * x; };
result =
@@ -156,6 +176,9 @@ result =
})();
assertEquals(4, result);
+
+
+
// Regression test: calling a function named eval found in a context that is
// not the global context should get the global object as receiver.
result =
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/regress/regress-221.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698