mirror of
https://github.com/tc39/test262.git
synced 2025-07-29 00:44:32 +02:00
Refactor misc. statement tests for parsers
The tests for the parsing of various statement were expressed using eval. This made the tests more complex than necessary and also prevented the tests from providing value to ECMAScript parsers. Remove the use of eval and instead express the expectations with literal source text. Rename the files to make each test's purpose more clear.
This commit is contained in:
parent
de567d3aa5
commit
aa4c533d28
@ -4,9 +4,11 @@
|
||||
/*---
|
||||
es5id: 12.1-1
|
||||
description: "12.1 - block '{ StatementListopt };' is not allowed: try-catch"
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("try{};catch(){}");
|
||||
});
|
||||
try{};catch(){}
|
||||
|
@ -6,9 +6,11 @@ es5id: 12.1-2
|
||||
description: >
|
||||
12.1 - block '{ StatementListopt };' is not allowed:
|
||||
try-catch-finally
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("try{};catch{};finally{}");
|
||||
});
|
||||
try{};catch{};finally{}
|
||||
|
@ -4,9 +4,11 @@
|
||||
/*---
|
||||
es5id: 12.1-3
|
||||
description: "12.1 - block '{ StatementListopt };' is not allowed: try-finally"
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("try{};finally{}");
|
||||
});
|
||||
try{};finally{}
|
||||
|
@ -4,9 +4,11 @@
|
||||
/*---
|
||||
es5id: 12.1-4
|
||||
description: "12.1 - block '{ StatementListopt };' is not allowed: if-else"
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("if{};else{}");
|
||||
});
|
||||
if{};else{}
|
||||
|
@ -4,9 +4,11 @@
|
||||
/*---
|
||||
es5id: 12.1-5
|
||||
description: "12.1 - block '{ StatementListopt };' is not allowed: if-else-if"
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("if{};else if{}");
|
||||
});
|
||||
if{};else if{}
|
||||
|
@ -6,9 +6,11 @@ es5id: 12.1-6
|
||||
description: >
|
||||
12.1 - block '{ StatementListopt };' is not allowed:
|
||||
if-else-if-else
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("if{};else if{};else{}");
|
||||
});
|
||||
if{};else if{};else{}
|
||||
|
@ -4,9 +4,11 @@
|
||||
/*---
|
||||
es5id: 12.1-7
|
||||
description: "12.1 - block '{ StatementListopt };' is not allowed: do-while"
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
eval("do{};while()");
|
||||
});
|
||||
do{};while()
|
||||
|
@ -1,66 +0,0 @@
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
Since LineTerminator between "break" and Identifier is not allowed,
|
||||
"break" is evaluated without label
|
||||
es5id: 12.8_A2
|
||||
description: >
|
||||
Checking by using eval, inserting LineTerminator between break and
|
||||
Identifier
|
||||
---*/
|
||||
|
||||
var result;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#1
|
||||
try{
|
||||
eval("FOR1 : for(var i=1;i<2;i++){ LABEL1 : do {var x =1;break\u000AFOR1;var y=2;} while(0);} result = i;");
|
||||
if (result!==2) {
|
||||
$ERROR('#1: Since LineTerminator(U-000A) between break and Identifier not allowed break evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#1.1: eval("FOR1 : for(var i=1;i<2;i++){ LABEL1 : do {var x =1;break\\u000AFOR1;var y=2;} while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#2
|
||||
try{
|
||||
eval("FOR2 : for(var i=1;i<2;i++){ LABEL2 : do {var x =1;break\u000DFOR2;var y=2;} while(0);} result = i;");
|
||||
if (result!==2) {
|
||||
$ERROR('#2: Since LineTerminator(U-000D) between break and Identifier not allowed break evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#2.1: eval("FOR2 : for(var i=1;i<2;i++){ LABEL2 : do {var x =1;break\\u000DFOR2;var y=2;} while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#3
|
||||
try{
|
||||
eval("FOR3 : for(var i=1;i<2;i++){ LABEL3 : do {var x =1;break\u2028FOR3;var y=2;} while(0);} result = i;");
|
||||
if (result!==2) {
|
||||
$ERROR('#3: Since LineTerminator(U-2028) between break and Identifier not allowed break evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#3.1: eval("FOR3 : for(var i=1;i<2;i++){ LABEL3 : do {var x =1;break\\u2028FOR3;var y=2;} while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#4
|
||||
try{
|
||||
eval("FOR4 : for(var i=1;i<2;i++){ LABEL4 : do {var x =1;break\u2029FOR4;var y=2;} while(0);} result = i;");
|
||||
if (result!==2) {
|
||||
$ERROR('#4: Since LineTerminator(U-2029) between break and Identifier not allowed break evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#4.1: eval("FOR4 : for(var i=1;i<2;i++){ LABEL4 : do {var x =1;break\\u2029FOR4;var y=2;} while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
45
test/language/statements/break/line-terminators.js
Normal file
45
test/language/statements/break/line-terminators.js
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
Since LineTerminator between "break" and Identifier is not allowed,
|
||||
"break" is evaluated without label
|
||||
es5id: 12.8_A2
|
||||
description: >
|
||||
Checking by using eval, inserting LineTerminator between break and
|
||||
Identifier
|
||||
---*/
|
||||
|
||||
FOR1 : for(var i=1;i<2;i++){
|
||||
LABEL1 : do {
|
||||
break
|
||||
FOR1;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(i, 2, '#1: Since LineTerminator(U-000A) between break and Identifier not allowed break evaluates without label');
|
||||
|
||||
FOR2 : for(var i=1;i<2;i++){
|
||||
LABEL2 : do {
|
||||
break
FOR2;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(i, 2, '#2: Since LineTerminator(U-000D) between break and Identifier not allowed break evaluates without label');
|
||||
|
||||
FOR3 : for(var i=1;i<2;i++){
|
||||
LABEL3 : do {
|
||||
break
FOR3;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(i, 2, '#3: Since LineTerminator(U-2028) between break and Identifier not allowed break evaluates without label');
|
||||
|
||||
FOR4 : for(var i=1;i<2;i++){
|
||||
LABEL4 : do {
|
||||
break
FOR4;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(i, 2, '#4: Since LineTerminator(U-2029) between break and Identifier not allowed break evaluates without label');
|
@ -1,66 +0,0 @@
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
Since LineTerminator between "continue" and Identifier is not allowed,
|
||||
"continue" is evaluated without label
|
||||
es5id: 12.7_A2
|
||||
description: >
|
||||
Checking by using eval, inserting LineTerminator between continue
|
||||
and Identifier
|
||||
---*/
|
||||
|
||||
var result;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#1
|
||||
try{
|
||||
eval("FOR1 : for(var i=1;i<2;i++){FOR1NESTED : for(var j=1;j<2;j++) { continue\u000AFOR1; } while(0);} result = j;");
|
||||
if (result!==2) {
|
||||
$ERROR('#1: Since LineTerminator(U-000A) between continue and Identifier not allowed continue evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#1.1: eval("FOR1 : for(var i=1;i<2;i++){FOR1NESTED : for(var j=1;j<2;j++) { continue\\u000AFOR1; } while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#2
|
||||
try{
|
||||
eval("FOR2 : for(var i=1;i<2;i++){FOR2NESTED : for(var j=1;j<2;j++) { continue\u000DFOR2; } while(0);} result = j;");
|
||||
if (result!==2) {
|
||||
$ERROR('#2: Since LineTerminator(U-000D) between continue and Identifier not allowed continue evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#2.1: eval("FOR2 : for(var i=1;i<2;i++){FOR2NESTED : for(var j=1;j<2;j++) { continue\\u000DFOR2; } while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#3
|
||||
try{
|
||||
eval("FOR3 : for(var i=1;i<2;i++){FOR3NESTED : for(var j=1;j<2;j++) { continue\u2028FOR3; } while(0);} result = j;");
|
||||
if (result!==2) {
|
||||
$ERROR('#3: Since LineTerminator(U-2028) between continue and Identifier not allowed continue evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#3.1: eval("FOR3 : for(var i=1;i<2;i++){FOR3NESTED : for(var j=1;j<2;j++) { continue\\u2028FOR3; } while(0);}") does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//CHECK#4
|
||||
try{
|
||||
eval("FOR4 : for(var i=1;i<2;i++){FOR4NESTED : for(var j=1;j<2;j++) { continue\u2029FOR4; } while(0);} result = j;");
|
||||
if (result!==2) {
|
||||
$ERROR('#4: Since LineTerminator(U-2029) between continue and Identifier not allowed continue evaluates without label');
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#4.1: eval("FOR4 : for(var i=1;i<2;i++){FOR4NESTED : for(var j=1;j<2;j++) { continue\\u2029FOR4; } while(0);}"); does not lead to throwing exception');
|
||||
}
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
44
test/language/statements/continue/line-terminators.js
Normal file
44
test/language/statements/continue/line-terminators.js
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
Since LineTerminator between "continue" and Identifier is not allowed,
|
||||
"continue" is evaluated without label
|
||||
es5id: 12.7_A2
|
||||
description: >
|
||||
Checking by using eval, inserting LineTerminator between continue
|
||||
and Identifier
|
||||
---*/
|
||||
|
||||
FOR1 : for(var i=1;i<2;i++){
|
||||
FOR1NESTED : for(var j=1;j<2;j++) {
|
||||
continue
|
||||
FOR1;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(j, 2, '#1: Since LineTerminator(U-000A) between continue and Identifier not allowed continue evaluates without label');
|
||||
|
||||
FOR2 : for(var i=1;i<2;i++){
|
||||
FOR2NESTED : for(var j=1;j<2;j++) {
|
||||
continue
FOR2;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(j, 2, '#2: Since LineTerminator(U-000D) between continue and Identifier not allowed continue evaluates without label');
|
||||
|
||||
FOR3 : for(var i=1;i<2;i++){
|
||||
FOR3NESTED : for(var j=1;j<2;j++) {
|
||||
continue
FOR3;
|
||||
} while(0);
|
||||
}
|
||||
assert.sameValue(j, 2, '#3: Since LineTerminator(U-2028) between continue and Identifier not allowed continue evaluates without label');
|
||||
|
||||
FOR4 : for(var i=1;i<2;i++){
|
||||
FOR4NESTED : for(var j=1;j<2;j++) {
|
||||
continue
FOR4;
|
||||
} while(0);
|
||||
}
|
||||
|
||||
assert.sameValue(j, 2, '#4: Since LineTerminator(U-2029) between continue and Identifier not allowed continue evaluates without label');
|
@ -1,57 +0,0 @@
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
LineTerminator between return and Identifier_opt yields return without
|
||||
Identifier_opt
|
||||
es5id: 12.9_A2
|
||||
description: >
|
||||
Checking by using eval, inserting LineTerminator between return
|
||||
and Variable
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
try{
|
||||
if (eval("(function(){var x = 1;return\u000Ax;var y=2;})()") !== undefined) {
|
||||
$ERROR("#1: LineTerminator(U-000A) between return and Identifier_opt yields return without Identifier_opt");
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#1: eval("(function(){var x = 1;return\\u000Ax;var y=2;})()") does not lead to throwing exception');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//CHECK#2
|
||||
try{
|
||||
if (eval("(function(){var x = 1;return\u000Dx;var y=2;})()") !== undefined) {
|
||||
$ERROR("#1: LineTerminator(U-000D) between return and Identifier_opt yields return without Identifier_opt");
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#2: eval("(function(){var x = 1;return\\u000Dx;var y=2;})()") does not lead to throwing exception');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//CHECK#3
|
||||
try{
|
||||
if (eval("(function(){var x = 1;return\u2028x;var y=2;})()") !== undefined) {
|
||||
$ERROR("#1: LineTerminator(U-2028) between return and Identifier_opt yields return without Identifier_opt");
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#3: eval("(function(){var x = 1;return\\u2028x;var y=2;})()") does not lead to throwing exception');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//CHECK#4
|
||||
try{
|
||||
if (eval("(function(){var x =1;return\u2029x;var y=2;})()") !== undefined) {
|
||||
$ERROR("#1: LineTerminator(U-2029) between return and Identifier_opt yields return without Identifier_opt");
|
||||
}
|
||||
} catch(e){
|
||||
$ERROR('#4: eval("(function(){var x =1;return\\u2029x;var y=2;})()") does not lead to throwing exception');
|
||||
}
|
36
test/language/statements/return/line-terminators.js
Normal file
36
test/language/statements/return/line-terminators.js
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
LineTerminator between return and Identifier_opt yields return without
|
||||
Identifier_opt
|
||||
es5id: 12.9_A2
|
||||
description: Inserting LineTerminator between return and Variable
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
function(){ return
|
||||
1; }(),
|
||||
undefined,
|
||||
"#1: LineTerminator(U-000A) between return and Identifier_opt yields return without Identifier_opt"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
function(){ return
1; }(),
|
||||
undefined,
|
||||
"#1: LineTerminator(U-000D) between return and Identifier_opt yields return without Identifier_opt"
|
||||
);
|
||||
|
||||
|
||||
assert.sameValue(
|
||||
function(){ return
1; }(),
|
||||
undefined,
|
||||
"#1: LineTerminator(U-2028) between return and Identifier_opt yields return without Identifier_opt"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
function(){ return
1; }(),
|
||||
undefined,
|
||||
"#1: LineTerminator(U-2029) between return and Identifier_opt yields return without Identifier_opt"
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user