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

Unified Diff: test/mjsunit/function.js

Issue 4248: Make sure that the body of the function created by calling Function is... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 3 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/v8natives.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698