Chromium Code Reviews| Index: test/mjsunit/eval.js |
| diff --git a/test/mjsunit/eval.js b/test/mjsunit/eval.js |
| index b6284ba911dece6ee77f74a8b46a81b8bfa45927..f26290da7071d133e6fa5f1915d7e946c90a1069 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 obj1 = { f: function(eval) { return eval("this"); } }; |
|
Rico
2011/10/31 08:14:56
Why the rename to obj1 (and obj2 below)
Lasse Reichstein
2011/10/31 09:37:46
Artifact of rewriting. At some point the var was o
|
| + result = obj1.f(eval); |
| + assertEquals(obj1, result); |
| +})(); |
| -result = |
| - (function() { |
| - var obj = { f: function(eval) { arguments; return eval("this"); } }; |
| - return obj.f(eval); |
| - })(); |
| -assertEquals(this, result); |
| +(function() { |
| + var obj2 = { f: function(eval) { arguments; return eval("this"); } }; |
| + result = obj2.f(eval); |
| + assertEquals(obj2, 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 = |