Fix strict mode errors in built-ins/Function

Add missing "var" declarations and noStrict flags.

Part of issue #35.
This commit is contained in:
André Bargull 2015-04-29 17:39:10 +02:00
parent 87fd4e5699
commit 0952011501
54 changed files with 96 additions and 75 deletions

View File

@ -7,8 +7,8 @@ es5id: 15.3.5_A3_T1
description: As constructor use Function("var x =1; this.y=2;return \"OK\";")
---*/
FACTORY = Function("var x =1; this.y=2;return \"OK\";");
obj = new FACTORY;
var FACTORY = Function("var x =1; this.y=2;return \"OK\";");
var obj = new FACTORY;
//CHECK#1
if (typeof obj !== "object") {

View File

@ -9,8 +9,8 @@ description: >
this.y=arg1+arg2;return \"OK\";")
---*/
FACTORY = new Function("arg1,arg2","var x =1; this.y=arg1+arg2;return \"OK\";");
obj = new FACTORY("1",2);
var FACTORY = new Function("arg1,arg2","var x =1; this.y=arg1+arg2;return \"OK\";");
var obj = new FACTORY("1",2);
//CHECK#1
if (typeof obj !== "object") {

View File

@ -10,7 +10,7 @@ description: Checking length property of Function("arg1,arg2,arg3", null)
includes: [$FAIL.js]
---*/
f = new Function("arg1,arg2,arg3", null);
var f = new Function("arg1,arg2,arg3", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {

View File

@ -12,7 +12,7 @@ description: >
includes: [$FAIL.js]
---*/
f = Function("arg1,arg2,arg3","arg4,arg5", null);
var f = Function("arg1,arg2,arg3","arg4,arg5", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {

View File

@ -12,7 +12,7 @@ description: >
includes: [$FAIL.js]
---*/
f = new Function("arg1,arg2,arg3","arg1,arg2","arg3", null);
var f = new Function("arg1,arg2,arg3","arg1,arg2","arg3", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {

View File

@ -10,7 +10,7 @@ description: >
includes: [$FAIL.js]
---*/
f = new Function("arg1,arg2,arg3", null);
var f = new Function("arg1,arg2,arg3", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {

View File

@ -10,7 +10,7 @@ description: >
includes: [$FAIL.js]
---*/
f = Function("arg1,arg2,arg3","arg4,arg5", null);
var f = Function("arg1,arg2,arg3","arg4,arg5", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {

View File

@ -10,7 +10,7 @@ description: >
includes: [$FAIL.js]
---*/
f = new Function("arg1,arg2,arg3","arg1,arg2","arg3", null);
var f = new Function("arg1,arg2,arg3","arg1,arg2","arg3", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {

View File

@ -7,6 +7,7 @@ es5id: 15.3.5.1_A3_T1
description: >
Checking if varying the length property of
Function("arg1,arg2,arg3","arg4,arg5", null) fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -7,6 +7,7 @@ es5id: 15.3.5.1_A3_T2
description: >
Checking if varying the length property of
Function("arg1,arg2,arg3", null) fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -7,6 +7,7 @@ es5id: 15.3.5.1_A3_T3
description: >
Checking if varying the length property of
Function("arg1,arg2,arg3","arg1,arg2","arg3", null) fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -10,14 +10,14 @@ description: >
includes: [$FAIL.js]
---*/
f = new Function("arg1,arg2,arg3", null);
var f = new Function("arg1,arg2,arg3", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {
$FAIL('#1: the function has length property.');
}
for(key in f)
for(var key in f)
if(key=="length")
var lengthenumed=true;

View File

@ -10,14 +10,14 @@ description: >
includes: [$FAIL.js]
---*/
f = Function("arg1,arg2,arg3","arg5,arg4", null);
var f = Function("arg1,arg2,arg3","arg5,arg4", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {
$FAIL('#1: the function has length property.');
}
for(key in f)
for(var key in f)
if(key=="length")
var lengthenumed=true;

View File

@ -10,14 +10,14 @@ description: >
includes: [$FAIL.js]
---*/
f = new Function("arg1,arg2,arg3","arg1,arg2","arg3", null);
var f = new Function("arg1,arg2,arg3","arg1,arg2","arg3", null);
//CHECK#1
if (!(f.hasOwnProperty('length'))) {
$FAIL('#1: the function has length property.');
}
for(key in f)
for(var key in f)
if(key=="length")
var lengthenumed=true;

View File

@ -5,6 +5,7 @@
info: The Function.prototype property has the attribute ReadOnly
es5id: 15.3.3.1_A1
description: Checking if varying the Function.prototype property fails
flags: [noStrict]
---*/
var obj = Function.prototype;

View File

@ -15,7 +15,7 @@ if (Function.propertyIsEnumerable('prototype')) {
// CHECK#2
var count=0;
for (p in Function){
for (var p in Function){
if (p==="prototype") count++;
}

View File

@ -5,6 +5,7 @@
info: The Function.prototype property has the attribute DontDelete
es5id: 15.3.3.1_A3
description: Checking if deleting the Function.prototype property fails
flags: [noStrict]
---*/
delete Function.prototype;

View File

@ -4,7 +4,7 @@
/*---
info: >
The Function prototype object is itself a Function object without
[[create]] property
[[Construct]] property
es5id: 15.3.4_A5
description: Checking if creating "new Function.prototype object" fails
includes:
@ -15,8 +15,8 @@ includes:
//CHECK#
try {
var obj = new Function.prototype;
$FAIL('#1: The Function prototype object is itself a Function object without [[create]] property: '+e);
$FAIL('#1: The Function prototype object is itself a Function object without [[Construct]] property: '+e);
} catch (e) {
$PRINT("#1.1: The Function prototype object is itself a Function object without [[create]] property "+e);
$PRINT("#1.1: The Function prototype object is itself a Function object without [[Construct]] property "+e);
}

View File

@ -7,6 +7,7 @@ es5id: 15.3.5.2_A1_T1
description: >
Checking if deleting the prototype property of Function("", null)
fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -7,6 +7,7 @@ es5id: 15.3.5.2_A1_T2
description: >
Checking if deleting the prototype property of Function(void 0,
"") fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -7,6 +7,7 @@ es5id: 15.3.4.3_A10
description: >
Checking if varying the Function.prototype.apply.length property
fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -7,6 +7,7 @@ info: >
object as the this value
es5id: 15.3.4.3_A3_T10
description: Checking by using eval, no any arguments at apply function
flags: [noStrict]
---*/
eval(" (function(){this.feat=1}).apply()");

View File

@ -9,6 +9,7 @@ es5id: 15.3.4.3_A3_T6
description: >
Argument at apply function is null and it called inside function
declaration
flags: [noStrict]
---*/
function FACTORY(){

View File

@ -9,6 +9,7 @@ es5id: 15.3.4.3_A3_T8
description: >
Argument at apply function is undefined and it called inside
function declaration
flags: [noStrict]
---*/
(function FACTORY(){

View File

@ -7,6 +7,7 @@ info: >
ToObject(thisArg) as the this value
es5id: 15.3.4.3_A5_T3
description: thisArg is string
flags: [noStrict]
---*/
var obj="soap";

View File

@ -7,6 +7,7 @@ info: >
ToObject(thisArg) as the this value
es5id: 15.3.4.3_A5_T4
description: thisArg is function variable that return this
flags: [noStrict]
---*/
f = function(){this.touched= true; return this;};

View File

@ -10,7 +10,7 @@ description: argArray is (object,"1,3,4")
includes: [$FAIL.js]
---*/
obj={};
var obj={};
//CHECK#1
try {

View File

@ -9,11 +9,11 @@ es5id: 15.3.4.3_A7_T3
description: argArray is (empty object, new Array("nine","inch","nails"))
---*/
i=0;
var i=0;
p={toString:function(){return "a"+(++i);}};
var p={toString:function(){return "a"+(++i);}};
obj={};
var obj={};
Function(p,"a2,a3","this.shifted=a1;").apply(obj, new Array("nine","inch","nails"));

View File

@ -11,11 +11,11 @@ description: >
("a","b","c"))
---*/
i=0;
var i=0;
p={toString:function(){return "a"+(++i);}};
var p={toString:function(){return "a"+(++i);}};
obj={};
var obj={};
new Function(p,p,p, "this.shifted=a3;").apply( obj,( function(){return arguments;}) ("a","b","c") );

View File

@ -13,7 +13,7 @@ function FACTORY(){
Function("a1,a2,a3","this.shifted=a1+a2+a3;").apply(null,arguments);
}
obj=new FACTORY("",1,2);
var obj=new FACTORY("",1,2);
//CHECK#1
if (this["shifted"] !== "12") {

View File

@ -13,7 +13,7 @@ function FACTORY(){
Function("a1,a2,a3","this.shifted=a1+a2+a3;").apply(this,arguments);
}
obj=new FACTORY("",4,2);
var obj=new FACTORY("",4,2);
//CHECK#1
if (obj["shifted"] !== "42") {

View File

@ -17,7 +17,7 @@ function FACTORY(){
return obj;
}
obj=new FACTORY("",1,2);
var obj=new FACTORY("",1,2);
//CHECK#1
if (typeof this["shifted"] !== "undefined") {

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.apply can`t be used as [[create]] caller
info: Function.prototype.apply can`t be used as [[Construct]] caller
es5id: 15.3.4.3_A8_T1
description: Checking if creating "new Function.prototype.apply" fails
---*/
try {
obj = new Function.prototype.apply;
$ERROR('#1: Function.prototype.apply can\'t be used as [[create]] caller');
var obj = new Function.prototype.apply;
$ERROR('#1: Function.prototype.apply can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.apply can`t be used as [[create]] caller
info: Function.prototype.apply can`t be used as [[Construct]] caller
es5id: 15.3.4.3_A8_T2
description: Checking if creating "new Function.prototype.apply()" fails
---*/
try {
obj = new Function.prototype.apply();
$ERROR('#1: Function.prototype.apply can\'t be used as [[create]] caller');
var obj = new Function.prototype.apply();
$ERROR('#1: Function.prototype.apply can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.apply can`t be used as [[create]] caller
info: Function.prototype.apply can`t be used as [[Construct]] caller
es5id: 15.3.4.3_A8_T3
description: Checking if creating "new Function.apply" fails
---*/
try {
obj = new Function.apply;
$ERROR('#1: Function.prototype.apply can\'t be used as [[create]] caller');
var obj = new Function.apply;
$ERROR('#1: Function.prototype.apply can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.apply can`t be used as [[create]] caller
info: Function.prototype.apply can`t be used as [[Construct]] caller
es5id: 15.3.4.3_A8_T4
description: Checking if creating "new (Function("this.p1=1").apply)" fails
---*/
try {
obj = new (Function("this.p1=1").apply);
$ERROR('#1: Function.prototype.apply can\'t be used as [[create]] caller');
var obj = new (Function("this.p1=1").apply);
$ERROR('#1: Function.prototype.apply can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,17 +2,17 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.apply can`t be used as [[create]] caller
info: Function.prototype.apply can`t be used as [[Construct]] caller
es5id: 15.3.4.3_A8_T5
description: Checking if creating "new Function("this.p1=1").apply" fails
---*/
try {
FACTORY = Function("this.p1=1").apply;
obj = new FACTORY();
$ERROR('#1: Function.prototype.apply can\'t be used as [[create]] caller');
var FACTORY = Function("this.p1=1").apply;
var obj = new FACTORY();
$ERROR('#1: Function.prototype.apply can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.apply can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.apply can`t be used as [[create]] caller
info: Function.prototype.apply can`t be used as [[Construct]] caller
es5id: 15.3.4.3_A8_T6
description: >
Checking if creating "new (Function("function
@ -11,12 +11,12 @@ description: >
//CHECK#1
try {
obj = new (Function("function f(){this.p1=1;};return f").apply());
var obj = new (Function("function f(){this.p1=1;};return f").apply());
} catch (e) {
$ERROR('#1: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.apply can\'t be used as [[Construct]] caller');
}
//CHECK#2
if (obj.p1!== 1) {
$ERROR('#2: Function.prototype.apply can\'t be used as [[create]] caller');
$ERROR('#2: Function.prototype.apply can\'t be used as [[Construct]] caller');
}

View File

@ -9,6 +9,7 @@ es5id: 15.3.4.5-15-3
description: >
Function.prototype.bind - The [[Writable]] attribute of length
property in F set as false
flags: [noStrict]
includes: [runTestCase.js]
---*/

View File

@ -7,6 +7,7 @@ es5id: 15.3.4.4_A10
description: >
Checking if varying the Function.prototype.call.length property
fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -22,7 +22,7 @@ if (Function.prototype.call.propertyIsEnumerable('length')) {
}
// CHECK#2
for (p in Function.prototype.call){
for (var p in Function.prototype.call){
if (p==="length")
$ERROR('#2: the Function.prototype.call.length property has the attributes DontEnum');
}

View File

@ -7,6 +7,7 @@ info: >
object as the this value
es5id: 15.3.4.4_A3_T10
description: Checking by using eval, no any arguments at call function
flags: [noStrict]
---*/
eval(" (function(){this.feat=1}).call()");

View File

@ -9,6 +9,7 @@ es5id: 15.3.4.4_A3_T6
description: >
Argument at call function is null and it called inside function
declaration
flags: [noStrict]
---*/
function FACTORY(){

View File

@ -9,6 +9,7 @@ es5id: 15.3.4.4_A3_T8
description: >
Argument at call function is undefined and it called inside
function declaration
flags: [noStrict]
---*/
(function FACTORY(){

View File

@ -7,6 +7,7 @@ info: >
ToObject(thisArg) as the this value
es5id: 15.3.4.4_A5_T3
description: thisArg is string
flags: [noStrict]
---*/
var obj="soap";

View File

@ -7,6 +7,7 @@ info: >
ToObject(thisArg) as the this value
es5id: 15.3.4.4_A5_T4
description: thisArg is function variable that return this
flags: [noStrict]
---*/
var f = function(){this.touched= true; return this;};

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.call can't be used as [[create]] caller
info: Function.prototype.call can't be used as [[Construct]] caller
es5id: 15.3.4.4_A7_T1
description: Checking if creating "new Function.prototype.call" fails
---*/
try {
var obj = new Function.prototype.call;
$ERROR('#1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.call can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.call can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.call can't be used as [[create]] caller
info: Function.prototype.call can't be used as [[Construct]] caller
es5id: 15.3.4.4_A7_T2
description: Checking if creating "new Function.prototype.call()" fails
---*/
@ -10,9 +10,9 @@ description: Checking if creating "new Function.prototype.call()" fails
try {
var FACTORY = Function.prototype.call;
var obj = new FACTORY();
$ERROR('#1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.call can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.call can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.call can't be used as [[create]] caller
info: Function.prototype.call can't be used as [[Construct]] caller
es5id: 15.3.4.4_A7_T3
description: Checking if creating "new Function.call" fails
---*/
try {
var obj = new Function.call;
$ERROR('#1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.call can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.call can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.call can't be used as [[create]] caller
info: Function.prototype.call can't be used as [[Construct]] caller
es5id: 15.3.4.4_A7_T4
description: Checking if creating "new (Function("this.p1=1").call)" fails
---*/
try {
var obj = new (Function("this.p1=1").call);
$ERROR('#1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.call can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.call can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.call can't be used as [[create]] caller
info: Function.prototype.call can't be used as [[Construct]] caller
es5id: 15.3.4.4_A7_T5
description: Checking if creating "new Function("this.p1=1").call" fails
---*/
@ -10,9 +10,9 @@ description: Checking if creating "new Function("this.p1=1").call" fails
try {
var FACTORY = Function("this.p1=1").call;
var obj = new FACTORY();
$ERROR('#1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.call can\'t be used as [[Construct]] caller');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1.1: Function.prototype.call can\'t be used as [[Construct]] caller');
}
}

View File

@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Function.prototype.call can't be used as [[create]] caller
info: Function.prototype.call can't be used as [[Construct]] caller
es5id: 15.3.4.4_A7_T6
description: >
Checking if creating "new (Function("function
@ -13,10 +13,10 @@ description: >
try {
var obj = new (Function("function f(){this.p1=1;};return f").call());
} catch (e) {
$ERROR('#1: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#1: Function.prototype.call can\'t be used as [[Construct]] caller');
}
//CHECK#2
if (obj.p1!== 1) {
$ERROR('#2: Function.prototype.call can\'t be used as [[create]] caller');
$ERROR('#2: Function.prototype.call can\'t be used as [[Construct]] caller');
}

View File

@ -7,6 +7,7 @@ es5id: 15.3.4.2_A10
description: >
Checking if varying the Function.prototype.toString.length
property fails
flags: [noStrict]
includes: [$FAIL.js]
---*/

View File

@ -22,7 +22,7 @@ if (Function.prototype.toString.propertyIsEnumerable('length')) {
}
// CHECK#2
for (p in Function.prototype.toString){
for (var p in Function.prototype.toString){
if (p==="length")
$ERROR('#2: the Function.prototype.toString.length property has the attributes DontEnum');
}