Skip to content
Snippets Groups Projects
Commit bb29020a authored by Mark Miller's avatar Mark Miller
Browse files
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.
parent 479a396f
No related branches found
No related tags found
No related merge requests found
Showing
with 165 additions and 334 deletions
......@@ -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;
......
// 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 );
}
//
//////////////////////////////////////////////////////////////////////////////
// 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(){};
}
});
// 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);
});
// 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(){};
};
// 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(){};
};
})();
// 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 );
}
//
//////////////////////////////////////////////////////////////////////////////
// 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);
}
//
//////////////////////////////////////////////////////////////////////////////
// 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 );
}
//
//////////////////////////////////////////////////////////////////////////////
// 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 );
}
//
//////////////////////////////////////////////////////////////////////////////
// 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());
}
//
//////////////////////////////////////////////////////////////////////////////
......@@ -2,15 +2,16 @@
// 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;
*/
* 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
*/
"use strict";
{
function __func(){}
}
......@@ -2,15 +2,16 @@
// 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;
*/
* 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
*/
"use strict";
if (true) {
function __func(){};
} else {
......
// 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(){};
}
});
......@@ -2,15 +2,16 @@
// 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;
* 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
*/
"use strict";
do{
do {
function __func(){};
} while(0);
// 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);
});
......@@ -2,17 +2,16 @@
// 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;
*/
* 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
*/
(function(){
for(x in this){
while (0) {
function __func(){};
};
})();
// 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(){};
};
})();
......@@ -2,13 +2,15 @@
// 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;
*/
* 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){
for (x in this) {
function __func(){};
};
}
// 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(){};
}
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment