Index: test/mjsunit/function.js |
=================================================================== |
--- test/mjsunit/function.js (revision 369) |
+++ test/mjsunit/function.js (working copy) |
@@ -27,36 +27,47 @@ |
var f = Function(); |
assertTrue(typeof f() == 'undefined'); |
-var f = new Function(); |
+f = new Function(); |
assertTrue(typeof f() == 'undefined'); |
-var f = Function('return 1'); |
+f = Function('return 1'); |
assertEquals(1, f()); |
-var f = new Function('return 1'); |
+f = new Function('return 1'); |
assertEquals(1, f()); |
-var f = Function('return true'); |
+f = Function('return true'); |
assertTrue(f()); |
-var f = new Function('return true'); |
+f = new Function('return true'); |
assertTrue(f()); |
-var f = Function('x', 'return x') |
+f = Function('x', 'return x'); |
assertEquals(1, f(1)); |
assertEquals('bar', f('bar')); |
assertTrue(typeof f() == 'undefined'); |
var x = {}; |
assertTrue(x === f(x)); |
-var f = new Function('x', 'return x') |
+ |
+f = Function('x', 'return x // comment'); |
assertEquals(1, f(1)); |
+ |
+f = Function('return typeof anonymous'); |
+assertEquals('undefined', f()); |
+ |
+var anonymous = 42; |
+f = Function('return anonymous;'); |
+assertEquals(42, f()); |
+ |
+f = new Function('x', 'return x') |
+assertEquals(1, f(1)); |
assertEquals('bar', f('bar')); |
assertTrue(typeof f() == 'undefined'); |
var x = {}; |
assertTrue(x === f(x)); |
-var f = Function('x', 'y', 'return x+y'); |
+f = Function('x', 'y', 'return x+y'); |
assertEquals(5, f(2, 3)); |
assertEquals('foobar', f('foo', 'bar')); |
-var f = new Function('x', 'y', 'return x+y'); |
+f = new Function('x', 'y', 'return x+y'); |
assertEquals(5, f(2, 3)); |
assertEquals('foobar', f('foo', 'bar')); |
@@ -66,7 +77,7 @@ |
var f = Function(x, y, z); |
assertEquals(25, f(5, 5)); |
assertEquals(42, f(2, 21)); |
-var f = new Function(x, y, z); |
+f = new Function(x, y, z); |
assertEquals(25, f(5, 5)); |
assertEquals(42, f(2, 21)); |