mirror of https://github.com/tc39/test262.git
Fix existing linting errors, update error phase, and add a new flags linter (#2086)
This commit is contained in:
parent
b78e085571
commit
c822f4c929
|
@ -10,7 +10,7 @@ description: >
|
|||
info: |
|
||||
HashbangComment::
|
||||
#! SingleLineCommentChars[opt]
|
||||
flags: [raw, noStrict]
|
||||
flags: [raw]
|
||||
features: [hashbang]
|
||||
---*/
|
||||
|
||||
|
|
|
@ -13,5 +13,5 @@ flags: [raw]
|
|||
---*/
|
||||
|
||||
"use strict"
|
||||
throw new Error("This code should not execute");
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
var public = 1;
|
||||
|
|
|
@ -13,5 +13,5 @@ flags: [raw]
|
|||
---*/
|
||||
|
||||
"use strict";
|
||||
throw new Error("This code should not execute");
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
var public = 1;
|
||||
|
|
|
@ -14,5 +14,5 @@ flags: [raw]
|
|||
|
||||
"use strict";
|
||||
"use strict";
|
||||
throw new Error("This code should not execute");
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
var public = 1;
|
||||
|
|
|
@ -13,5 +13,5 @@ flags: [raw]
|
|||
---*/
|
||||
|
||||
"use strict";
|
||||
throw new Error("This code should not execute");
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
eval = 42;
|
||||
|
|
|
@ -15,5 +15,5 @@ flags: [raw]
|
|||
"a";
|
||||
"use strict";
|
||||
"c";
|
||||
throw new Error("This code should not execute");
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
eval = 42;
|
||||
|
|
|
@ -9,11 +9,13 @@ description: >
|
|||
is strict function code if FunctionDeclaration is contained in use
|
||||
strict
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
function testcase() {
|
||||
"use strict";
|
||||
function fun() {
|
||||
|
|
|
@ -8,11 +8,13 @@ description: >
|
|||
Strict Mode - Use Strict Directive Prologue is ''use strict''
|
||||
which lost the last character ';'
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
function fun() {
|
||||
"use strict"
|
||||
var static;
|
||||
|
|
|
@ -8,11 +8,13 @@ description: >
|
|||
Strict Mode - Function code of a FunctionDeclaration contains Use
|
||||
Strict Directive which appears at the start of the block
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
function fun() {
|
||||
"use strict";
|
||||
var static;
|
||||
|
|
|
@ -9,11 +9,13 @@ description: >
|
|||
is strict function code if FunctionExpression is contained in use
|
||||
strict
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
function testcase() {
|
||||
"use strict";
|
||||
var static;
|
||||
|
|
|
@ -8,11 +8,13 @@ description: >
|
|||
Strict Mode - Use Strict Directive Prologue is ''use strict''
|
||||
which lost the last character ';'
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
(function() {
|
||||
"use strict"
|
||||
|
||||
|
|
|
@ -8,11 +8,13 @@ description: >
|
|||
Strict Mode - Function code of a FunctionExpression contains Use
|
||||
Strict Directive which appears at the start of the block
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ description: >
|
|||
info: |
|
||||
It is an early Syntax Error if Module is not the syntactic goal symbol.
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta]
|
||||
---*/
|
||||
|
|
|
@ -21,7 +21,7 @@ info: |
|
|||
and AssignmentTargetType(LeftHandSideExpression) is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta, destructuring-assignment]
|
||||
---*/
|
||||
|
|
|
@ -21,7 +21,7 @@ info: |
|
|||
and AssignmentTargetType(LeftHandSideExpression) is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta, destructuring-assignment]
|
||||
---*/
|
||||
|
|
|
@ -21,7 +21,7 @@ info: |
|
|||
ArrayLiteral and AssignmentTargetType of LeftHandSideExpression is invalid.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: ReferenceError
|
||||
features: [import.meta]
|
||||
---*/
|
||||
|
|
|
@ -20,7 +20,7 @@ info: |
|
|||
It is a Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta, async-iteration]
|
||||
---*/
|
||||
|
|
|
@ -20,7 +20,7 @@ info: |
|
|||
It is a Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta]
|
||||
---*/
|
||||
|
|
|
@ -20,7 +20,7 @@ info: |
|
|||
It is a Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta]
|
||||
---*/
|
||||
|
|
|
@ -21,7 +21,7 @@ info: |
|
|||
and AssignmentTargetType(LeftHandSideExpression) is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta, destructuring-assignment]
|
||||
---*/
|
||||
|
|
|
@ -21,7 +21,7 @@ info: |
|
|||
and AssignmentTargetType(LeftHandSideExpression) is not simple.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
features: [import.meta, destructuring-assignment, object-rest]
|
||||
---*/
|
||||
|
|
|
@ -22,7 +22,7 @@ info: |
|
|||
It is an early Reference Error if AssignmentTargetType of LeftHandSideExpression is invalid.
|
||||
flags: [module]
|
||||
negative:
|
||||
phase: early
|
||||
phase: parse
|
||||
type: ReferenceError
|
||||
features: [import.meta]
|
||||
---*/
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
from ..check import Check
|
||||
|
||||
class CheckFlags(Check):
|
||||
'''Ensure tests don't contain any contradicting or redundant flag combinations.'''
|
||||
ID = 'FLAGS'
|
||||
|
||||
def run(self, name, meta, source):
|
||||
if meta is None or meta.get('flags') is None:
|
||||
return
|
||||
|
||||
flags = meta['flags']
|
||||
|
||||
onlyStrict = 'onlyStrict' in flags
|
||||
noStrict = 'noStrict' in flags
|
||||
module = 'module' in flags
|
||||
raw = 'raw' in flags
|
||||
canBlockIsFalse = 'CanBlockIsFalse' in flags
|
||||
canBlockIsTrue = 'CanBlockIsTrue' in flags
|
||||
|
||||
if onlyStrict and noStrict:
|
||||
return '"onlyStrict" and "noStrict" flags are mutually exclusive'
|
||||
|
||||
if canBlockIsFalse and canBlockIsTrue:
|
||||
return '"CanBlockIsFalse" and "CanBlockIsTrue" flags are mutually exclusive'
|
||||
|
||||
if raw and onlyStrict:
|
||||
return 'Raw tests cannot prepend a "use strict" directive'
|
||||
|
||||
if raw and noStrict:
|
||||
return '"raw" flag implies no "use strict" directive should be prepended'
|
||||
|
||||
if module and onlyStrict:
|
||||
return 'Module tests cannot be run in non-strict mode'
|
||||
|
||||
if module and noStrict:
|
||||
return '"module" flag implies the test is run in strict mode'
|
|
@ -27,6 +27,9 @@ class CheckNegative(Check):
|
|||
if not 'phase' in negative:
|
||||
return '"negative" must specify a "phase" field'
|
||||
|
||||
if negative["phase"] not in ["parse", "resolution", "runtime"]:
|
||||
return '"phase" must be one of ["parse", "resolution", "runtime"]'
|
||||
|
||||
if negative["phase"] in ["parse", "resolution"]:
|
||||
if meta.get('flags') and 'raw' in meta['flags']:
|
||||
if not _THROW_STMT_LEGACY.search(source):
|
||||
|
|
|
@ -38,6 +38,7 @@ from lib.checks.license import CheckLicense
|
|||
from lib.checks.negative import CheckNegative
|
||||
from lib.checks.filename import CheckFileName
|
||||
from lib.checks.nopadding import CheckNoPadding
|
||||
from lib.checks.flags import CheckFlags
|
||||
from lib.eprint import eprint
|
||||
import lib.frontmatter
|
||||
import lib.exceptions
|
||||
|
@ -59,7 +60,8 @@ checks = [
|
|||
CheckHarness(),
|
||||
CheckLicense(),
|
||||
CheckNegative(),
|
||||
CheckNoPadding()
|
||||
CheckNoPadding(),
|
||||
CheckFlags(),
|
||||
]
|
||||
|
||||
def lint(file_names):
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
FLAGS
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
flags: [CanBlockIsFalse, CanBlockIsTrue]
|
||||
---*/
|
|
@ -0,0 +1,9 @@
|
|||
FLAGS
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
flags: [module, noStrict]
|
||||
---*/
|
|
@ -0,0 +1,9 @@
|
|||
FLAGS
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
flags: [module, onlyStrict]
|
||||
---*/
|
|
@ -0,0 +1,9 @@
|
|||
FLAGS
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
flags: [onlyStrict, noStrict]
|
||||
---*/
|
|
@ -0,0 +1,9 @@
|
|||
FLAGS
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
flags: [raw, noStrict]
|
||||
---*/
|
|
@ -0,0 +1,9 @@
|
|||
FLAGS
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
flags: [raw, onlyStrict]
|
||||
---*/
|
|
@ -0,0 +1,16 @@
|
|||
NEGATIVE
|
||||
^ expected errors | v input
|
||||
// Copyright (C) 2019 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-assignment-operators-static-semantics-early-errors
|
||||
description: Minimal test
|
||||
negative:
|
||||
type: SyntaxError
|
||||
phase: early
|
||||
flags: [raw]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
!!!
|
Loading…
Reference in New Issue