Revision: 6501
Author: [email protected]
Date: Wed Jan 26 10:10:26 2011
Log: Strict mode: function constructor tests.
http://code.google.com/p/v8/source/detail?r=6501

Modified:
 /branches/bleeding_edge/test/mjsunit/strict-mode.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/strict-mode.js Tue Jan 25 10:42:35 2011 +++ /branches/bleeding_edge/test/mjsunit/strict-mode.js Wed Jan 26 10:10:26 2011
@@ -43,6 +43,23 @@
       "\n}\
     }", exception);
 }
+
+function CheckFunctionConstructorStrictMode() {
+  var args = [];
+  for (var i = 0; i < arguments.length; i ++) {
+    args[i] = arguments[i];
+  }
+  // Create non-strict function. No exception.
+  args[arguments.length] = "";
+  assertDoesNotThrow(function() {
+    Function.apply(this, args);
+  });
+  // Create strict mode function. Exception expected.
+  args[arguments.length] = "'use strict';";
+  assertThrows(function() {
+    Function.apply(this, args);
+  }, SyntaxError);
+}

 // Incorrect 'use strict' directive.
 function UseStrictEscape() {
@@ -90,6 +107,16 @@
 // Duplicate function parameter name.
 CheckStrictMode("function foo(a, b, c, d, b) {}", SyntaxError)

+// Function constructor: eval parameter name.
+CheckFunctionConstructorStrictMode("eval")
+
+// Function constructor: arguments parameter name.
+CheckFunctionConstructorStrictMode("arguments")
+
+// Function constructor: duplicate parameter name.
+CheckFunctionConstructorStrictMode("a", "b", "c", "b")
+CheckFunctionConstructorStrictMode("a,b,c,b")
+
 // catch(eval)
 CheckStrictMode("try{}catch(eval){};", SyntaxError)

@@ -144,8 +171,6 @@
   var x = { 123 : 1, "0123" : 2 };
var x = { 123: 1, '123.00000000000000000000000000000000000000000000000000000000000000000001' : 2 }
 }
-
-//CheckStrictMode("", SyntaxError)

 // Two getters (non-strict)
 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError)

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to