Commit 55400c24 authored by mmaly@chromium.org's avatar mmaly@chromium.org

Strict mode: function constructor tests.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6501 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c1bbd04d
......@@ -44,6 +44,23 @@ function CheckStrictMode(code, exception) {
}", 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() {
"use\\x20strict";
......@@ -90,6 +107,16 @@ CheckStrictMode("var o = { set foo(arguments) {} }", SyntaxError)
// 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)
......@@ -145,8 +172,6 @@ function StrictModeNonDuplicate() {
var x = { 123: 1, '123.00000000000000000000000000000000000000000000000000000000000000000001' : 2 }
}
//CheckStrictMode("", SyntaxError)
// Two getters (non-strict)
assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError)
assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment