mirror of
https://github.com/tc39/test262.git
synced 2025-07-24 22:45:10 +02:00
Merge pull request #2117 from jugglinmike/refactor-for-parsers-misc-stmts
Refactor misc. statement tests for parsers
This commit is contained in:
commit
cd1df5fae2
@ -4,9 +4,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1-1
|
es5id: 12.1-1
|
||||||
description: "12.1 - block '{ StatementListopt };' is not allowed: try-catch"
|
description: "12.1 - block '{ StatementListopt };' is not allowed: try-catch"
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
try{};catch(){}
|
||||||
eval("try{};catch(){}");
|
|
||||||
});
|
|
||||||
|
@ -6,9 +6,11 @@ es5id: 12.1-2
|
|||||||
description: >
|
description: >
|
||||||
12.1 - block '{ StatementListopt };' is not allowed:
|
12.1 - block '{ StatementListopt };' is not allowed:
|
||||||
try-catch-finally
|
try-catch-finally
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
try{};catch{};finally{}
|
||||||
eval("try{};catch{};finally{}");
|
|
||||||
});
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1-3
|
es5id: 12.1-3
|
||||||
description: "12.1 - block '{ StatementListopt };' is not allowed: try-finally"
|
description: "12.1 - block '{ StatementListopt };' is not allowed: try-finally"
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
try{};finally{}
|
||||||
eval("try{};finally{}");
|
|
||||||
});
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1-4
|
es5id: 12.1-4
|
||||||
description: "12.1 - block '{ StatementListopt };' is not allowed: if-else"
|
description: "12.1 - block '{ StatementListopt };' is not allowed: if-else"
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
if{};else{}
|
||||||
eval("if{};else{}");
|
|
||||||
});
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1-5
|
es5id: 12.1-5
|
||||||
description: "12.1 - block '{ StatementListopt };' is not allowed: if-else-if"
|
description: "12.1 - block '{ StatementListopt };' is not allowed: if-else-if"
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
if{};else if{}
|
||||||
eval("if{};else if{}");
|
|
||||||
});
|
|
||||||
|
@ -6,9 +6,11 @@ es5id: 12.1-6
|
|||||||
description: >
|
description: >
|
||||||
12.1 - block '{ StatementListopt };' is not allowed:
|
12.1 - block '{ StatementListopt };' is not allowed:
|
||||||
if-else-if-else
|
if-else-if-else
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
if{};else if{};else{}
|
||||||
eval("if{};else if{};else{}");
|
|
||||||
});
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.1-7
|
es5id: 12.1-7
|
||||||
description: "12.1 - block '{ StatementListopt };' is not allowed: do-while"
|
description: "12.1 - block '{ StatementListopt };' is not allowed: do-while"
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
do{};while()
|
||||||
eval("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,26 +0,0 @@
|
|||||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: |
|
|
||||||
The result of evaluating "for( ExpNoIn;Exp;Exp)" loop is returning
|
|
||||||
(normal, evalValue, empty)
|
|
||||||
es5id: 12.6.3_A9.1
|
|
||||||
description: Using eval
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var supreme, count;
|
|
||||||
supreme=5;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CHECK#
|
|
||||||
try {
|
|
||||||
var __evaluated = eval("for(count=0;;) {if (count===supreme)break;else count++; }");
|
|
||||||
if (__evaluated !== void 0) {
|
|
||||||
$ERROR('#1: __evaluated === 4. Actual: __evaluated ==='+ __evaluated );
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
$ERROR('#1: var __evaluated = eval("for(count=0;;) {if (count===supreme)break;else count++; }"); does not lead to throwing exception');
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: |
|
|
||||||
The result of evaluating "for(var ExpNoIn;Exp;Exp)" loop is returning
|
|
||||||
(normal, evalValue, empty)
|
|
||||||
es5id: 12.6.3_A9
|
|
||||||
description: Using eval
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var supreme;
|
|
||||||
supreme=5;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CHECK#
|
|
||||||
try {
|
|
||||||
var __evaluated = eval("for(var count=0;;) {if (count===supreme)break;else count++; }");
|
|
||||||
if (__evaluated !== void 0) {
|
|
||||||
$ERROR('#1: __evaluated === 4. Actual: __evaluated ==='+ __evaluated );
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
$ERROR('#1: var __evaluated = eval("for(var count=0;;) {if (count===supreme)break;else count++; }"); does not lead to throwing exception');
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -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.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
info: |
|
||||||
|
The result of evaluating "for( ExpNoIn;Exp;Exp)" loop is returning
|
||||||
|
(normal, evalValue, empty)
|
||||||
|
es5id: 12.6.3_A9.1
|
||||||
|
description: Using eval
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var supreme, count;
|
||||||
|
supreme=5;
|
||||||
|
|
||||||
|
var __evaluated = eval("for(count=0;;) {if (count===supreme)break;else count++; }");
|
||||||
|
|
||||||
|
assert.sameValue(__evaluated, void 0, '#1: __evaluated === 4. Actual: __evaluated ==='+ __evaluated);
|
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2019 Mike Pennisi. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: For head may omit optional expressions
|
||||||
|
es5id: 12.6.3_A9.1
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
var supreme = 5
|
||||||
|
var count;
|
||||||
|
|
||||||
|
for(count=0;;) {if (count===supreme)break;else count++; }
|
@ -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.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
info: |
|
||||||
|
The result of evaluating "for(var ExpNoIn;Exp;Exp)" loop is returning
|
||||||
|
(normal, evalValue, empty)
|
||||||
|
es5id: 12.6.3_A9
|
||||||
|
description: Using eval
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var supreme=5;
|
||||||
|
|
||||||
|
var __evaluated = eval("for(var count=0;;) {if (count===supreme)break;else count++; }");
|
||||||
|
|
||||||
|
assert.sameValue(__evaluated, void 0, '#1: __evaluated === 4. Actual: __evaluated ==='+ __evaluated );
|
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2019 Mike Pennisi. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: For head may omit optional expressions
|
||||||
|
es5id: 12.6.3_A9
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var supreme=5;
|
||||||
|
|
||||||
|
for(var count=0;;) {if (count===supreme)break;else count++; }
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
info: |
|
|
||||||
In the "if" statement empty statement is allowed and is evaluated to
|
|
||||||
"undefined"
|
|
||||||
es5id: 12.5_A7
|
|
||||||
description: Checking by using eval "eval("if(1);"))"
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CHECK#1
|
|
||||||
try {
|
|
||||||
var __evaluated = eval("if(1);");
|
|
||||||
if (__evaluated !== undefined) {
|
|
||||||
$ERROR('#1: __evaluated === undefined. Actual: __evaluated ==='+ __evaluated );
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
$ERROR('#1.1: "__evaluated = eval("if(1);")" does not lead to throwing exception');
|
|
||||||
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
14
test/language/statements/if/cptn-empty-statement.js
Normal file
14
test/language/statements/if/cptn-empty-statement.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
info: |
|
||||||
|
In the "if" statement empty statement is allowed and is evaluated to
|
||||||
|
"undefined"
|
||||||
|
es5id: 12.5_A7
|
||||||
|
description: Checking by using eval "eval("if(1);"))"
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var __evaluated = eval("if(1);");
|
||||||
|
|
||||||
|
assert.sameValue(__evaluated, undefined, '#1: __evaluated === undefined. Actual: __evaluated ==='+ __evaluated);
|
9
test/language/statements/if/empty-statement.js
Normal file
9
test/language/statements/if/empty-statement.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2019 Mike Pennisi. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: In the "if" statement empty statement is allowed.
|
||||||
|
es5id: 12.5_A7
|
||||||
|
---*/
|
||||||
|
|
||||||
|
if(1);
|
@ -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