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 = |