these tests were valid tests of best practices, but not of the
normative spec. We moved these to a new bestPractices directory and
added a new not-yet-operational @bestPractices property.
This commit is contained in:
Mark Miller 2011-09-24 16:08:47 -07:00
parent 479a396ffd
commit bb29020ab2
25 changed files with 165 additions and 416 deletions

View File

@ -6,7 +6,7 @@
* @section: 12.10;
* @assertion: No matter how control leaves the embedded 'Statement', the scope chain is always restored to its former state;
* @description: Declaring "with" statement within a function constructor, leading to completion by exception;
* @strict_mode_negative
* @noStrict
*/
this.p1 = 1;

View File

@ -1,58 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.10_A3.3_T5;
* @section: 12.10;
* @assertion: No matter how control leaves the embedded 'Statement',
* the scope chain is always restored to its former state;
* @description: Declaring "with" statement within a function constructor, leading to completion by exception;
* @strict_mode_negative
*/
this.p1 = 1;
var result = "result";
var myObj = {
p1: 'a',
value: 'myObj_value',
valueOf : function(){return 'obj_valueOf';}
}
try {
function __FACTORY(){
with(myObj){
throw value;
p1 = 'x1';
}
}
var obj = new __FACTORY();
} catch(e){
result = p1;
}
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if(result !== 1){
$ERROR('#1: result === 1. Actual: result ==='+ result );
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if(p1 !== 1){
$ERROR('#2: p1 === 1. Actual: p1 ==='+ p1 );
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#3
if(myObj.p1 !== "a"){
$ERROR('#3: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,16 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.1_A1;
* @section: 12.1;
* @assertion: The production Block { } in strict code can't contain function declaration;
* @description: Trying to declare function at the Block statement;
* @negative
* @errortype: SyntaxError;
*/
"use strict";
{
function __func(){}
}

View File

@ -1,18 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.5_A9_T1;
* @section: 12.5;
* @assertion: Function declaration within an "if" statement in strict code is not allowed;
* @description: Declaring function within an "if" statement;
* @negative
* @errortype: SyntaxError;
*/
"use strict";
if (true) {
function __func(){};
} else {
function __func(){};
}

View File

@ -1,22 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.5_A9_T2;
* @section: 12.5;
* @assertion: Function declaration within an "if" statement in strict code is not allowed;
* @description: Declaring function within an "if" that is declared within the strict function;
* @negative
* @errortype: SyntaxError;
*/
(function(){
"use strict";
if (true) {
function __func(){};
} else {
function __func(){};
}
});

View File

@ -1,16 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.6.1_A13_T1;
* @section: 12.6.1, 13;
* @assertion: FunctionDeclaration within a "do-while" Block in strict code is not allowed;
* @description: Declaring function within a "do-while" loop;
* @negative
* @errortype: SyntaxError;
*/
"use strict";
do{
function __func(){};
} while(0);

View File

@ -1,19 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.6.1_A13_T2;
* @section: 12.6.1, 13;
* @assertion: FunctionDeclaration within a "do-while" Block in strict code is not allowed;
* @description: Declaring a function within a "do-while" loop that is within a strict function;
* @negative
* @errortype: SyntaxError;
*/
(function(){
"use strict";
do{
function __func(){};
}while(0);
});

View File

@ -1,14 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.6.2_A13_T1;
* @section: 12.6.2;
* @assertion: FunctionDeclaration within a "while" Statement is not allowed;
* @description: Checking if declaring a function within a "while" Statement leads to an exception;
* @negative;
*/
while(0){
function __func(){};
};

View File

@ -1,18 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.6.2_A13_T2;
* @section: 12.6.2;
* @assertion: FunctionDeclaration within a "while" Statement is not allowed;
* @description: Checking if declaring a function within a "while" Statement that is in a function call leads to an exception;
* @negative;
*/
(function(){
while(0){
function __func(){};
};
})();

View File

@ -1,14 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.6.4_A13_T1;
* @section: 12.6.4;
* @assertion: FunctionDeclaration within a "for-in" Statement is not allowed;
* @description: Declaring function within a "for-in" Statement;
* @negative;
*/
for(x in this){
function __func(){};
};

View File

@ -1,18 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.6.4_A13_T2;
* @section: 12.6.4;
* @assertion: FunctionDeclaration within a "for-in" Statement is not allowed;
* @description: Declaring function within a "for-in" Statement that is within a function call;
* @negative;
*/
(function(){
for(x in this){
function __func(){};
};
})();

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.7_A3;
* @section: 12.7;
* @assertion: When "continue Identifier" is evaluated (continue, empty, empty) is returned;
* @description: Simple using continue without Identifier and labeled loop;
*/
LABEL_OUT : var x=0, y=0;
LABEL_DO_LOOP : do {
LABEL_IN : x=2;
continue ;
LABEL_IN_2 : var y=2;
function IN_DO_FUNC(){}
} while(0);
LABEL_ANOTHER_LOOP : do {
;
} while(0);
function OUT_FUNC(){}
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if ((x!==2)&&(y!==0)) {
$ERROR('#1: x === 2 and y === 0. Actual: x ==='+x+' and y ==='+ y );
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,34 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.7_A4_T1;
* @section: 12.7;
* @assertion: When "continue Identifier" is evaluated (continue, empty, Identifier) is returned;
* @description: Simple using continue Identifier construction;
*/
LABEL_OUT : var x=0, y=0;
LABEL_DO_LOOP : do {
LABEL_IN : x++;
if(x===10)break;
continue LABEL_DO_LOOP;
LABEL_IN_2 : y++;
function IN_DO_FUNC(){}
} while(0);
LABEL_ANOTHER_LOOP : do {
;
} while(0);
function OUT_FUNC(){}
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if ((x!==1)&&(y!==0)) {
$ERROR('#1: x===1 and y === 0. Actual: x==='+x+' and y ==='+y);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,40 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.7_A4_T2;
* @section: 12.7;
* @assertion: When "continue Identifier" is evaluated (continue, empty, Identifier) is returned;
* @description: Using embedded and labeled loops, continue to nested loop;
*/
LABEL_OUT : var x=0, y=0, xx=0, yy=0;
LABEL_DO_LOOP : do {
LABEL_IN : x++;
if(x===10)break;
LABEL_NESTED_LOOP : do {
LABEL_IN_NESTED : xx++;
if(xx===10)break;
continue LABEL_NESTED_LOOP;
LABEL_IN_NESTED_2 : yy++;
} while (0);
LABEL_IN_2 : y++;
function IN_DO_FUNC(){}
} while(0);
LABEL_ANOTHER_LOOP : do {
;
} while(0);
function OUT_FUNC(){}
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if ((x!==1)&&(y!==1)&&(xx!==1)&(yy!==0)) {
$ERROR('#1: (x===1) and (y===1) and (xx===1) and (yy===0). Actual: x==='+x+' and y==='+y+' and xx==='+xx+' and yy==='+yy );
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,40 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S12.7_A4_T3;
* @section: 12.7;
* @assertion: When "continue Identifier" is evaluated (continue, empty, Identifier) is returned;
* @description: Using embedded and labeled loops, continue to outer loop;
*/
LABEL_OUT : var x=0, y=0, xx=0, yy=0;
LABEL_DO_LOOP : do {
LABEL_IN : x++;
if(x===10)break;
LABEL_NESTED_LOOP : do {
LABEL_IN_NESTED : xx++;
if(xx===10)break;
continue LABEL_DO_LOOP;
LABEL_IN_NESTED_2 : yy++;
} while (0);
LABEL_IN_2 : y++;
function IN_DO_FUNC(){}
} while(0);
LABEL_ANOTHER_LOOP : do {
;
} while(0);
function OUT_FUNC(){}
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if ((x!==1)&&(y!==0)&&(xx!==1)&(yy!==0)) {
$ERROR('#1: (x===1) and (y===0) and (xx===1) and (yy===0). Actual: x==='+x+' and y==='+y+' and xx==='+xx+' and yy==='+yy );
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,55 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @name: S13.2.2_A17_T1;
* @section: 13.2.2;
* @assertion: FunctionExpression containing "with" statement is admitted;
* @description: Using "with" statement within a function body;
*/
var p1="alert";
var __obj={p1:1,getRight:function(){return "right";}};
this.getRight=function(){return "napravo";};
(function(){
with(__obj){
p1="w1";
function getRight(){return false;}
}
})();
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (p1!=="alert") {
$ERROR('#1: p1 === "alert". Actual: p1==='+p1);
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (getRight()!=="napravo") {
$ERROR('#2: getRight() === "napravo". Actual: getRight() === '+getRight());
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#3
if (__obj.p1!=="w1") {
$ERROR('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1);
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#4
if (__obj.getRight()!=="right") {
$ERROR('#4: __obj.getRight() === "right". Actual: __obj.getRight() ==='+__obj.getRight());
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,17 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* The production Block { } in strict code can't contain function
* declaration;
*
* @description: Trying to declare function at the Block statement;
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
{
function __func(){}
}

View File

@ -0,0 +1,19 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Function declaration within an "if" statement in strict code is not
* allowed
*
* @description Declaring function within a strict "if" statement
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
if (true) {
function __func(){};
} else {
function __func(){};
}

View File

@ -0,0 +1,21 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Function declaration within an "if" statement in strict code is not allowed;
*
* @description Declaring function within an "if" that is declared
* within the strict function
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
(function(){
if (true) {
function __func(){};
} else {
function __func(){};
}
});

View File

@ -0,0 +1,17 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration within a "do-while" Block in strict code is not
* allowed
*
* @description Declaring function within a "do-while" loop
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
do {
function __func(){};
} while(0);

View File

@ -0,0 +1,19 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration within a "do-while" Block in strict code is not allowed
*
* @description Declaring a function within a "do-while" loop that is
* within a strict function
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
(function(){
do {
function __func(){};
} while(0);
});

View File

@ -0,0 +1,17 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration within a "while" Statement is not allowed
*
* @description Checking if declaring a function within a "while"
* Statement leads to an exception
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
while (0) {
function __func(){};
};

View File

@ -0,0 +1,19 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration within a "while" Statement is not allowed
*
* @description Checking if declaring a function within a "while"
* Statement that is in a function call leads to an exception
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
(function(){
while (0) {
function __func(){};
};
})();

View File

@ -0,0 +1,16 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration within a "for-in" Statement is not allowed
*
* @description: Declaring function within a "for-in" Statement
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
for (x in this) {
function __func(){};
}

View File

@ -0,0 +1,19 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* FunctionDeclaration within a "for-in" Statement is not allowed
*
* @description Declaring function within a "for-in" Statement that is
* within a function call
* @negative SyntaxError
* @onlyStrict
* @bestPractice
* http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
*/
(function(){
for (x in this) {
function __func(){};
}
})();