mirror of https://github.com/tc39/test262.git
Linter should require direct throw statement for raw tests instead of DONOTEVALUATE
This commit is contained in:
parent
f13a0c5aaf
commit
8e0c0eac10
|
@ -5,6 +5,10 @@ _THROW_STMT = re.compile(
|
||||||
r'^\$DONOTEVALUATE\(\);$',
|
r'^\$DONOTEVALUATE\(\);$',
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
|
|
||||||
|
_THROW_STMT_LEGACY = re.compile(
|
||||||
|
r'^throw "Test262: This statement should not be evaluated\.";$',
|
||||||
|
re.MULTILINE)
|
||||||
|
|
||||||
class CheckNegative(Check):
|
class CheckNegative(Check):
|
||||||
'''Ensure tests have the expected YAML-formatted metadata.'''
|
'''Ensure tests have the expected YAML-formatted metadata.'''
|
||||||
ID = 'NEGATIVE'
|
ID = 'NEGATIVE'
|
||||||
|
@ -23,5 +27,9 @@ class CheckNegative(Check):
|
||||||
if not 'phase' in negative:
|
if not 'phase' in negative:
|
||||||
return '"negative" must specify a "phase" field'
|
return '"negative" must specify a "phase" field'
|
||||||
|
|
||||||
if negative["phase"] in ["parse", "resolution"] and not _THROW_STMT.search(source):
|
if negative["phase"] in ["parse", "resolution"]:
|
||||||
return 'Negative tests of type "early" must include a `throw` statement'
|
if meta.get('flags') and 'raw' in meta['flags']:
|
||||||
|
if not _THROW_STMT_LEGACY.search(source):
|
||||||
|
return 'Negative tests of type "early" must include a `throw` statement'
|
||||||
|
elif not _THROW_STMT.search(source):
|
||||||
|
return 'Negative tests of type "early" must include a $DONOTEVALUATE() call'
|
||||||
|
|
|
@ -9,4 +9,6 @@ negative:
|
||||||
type: SyntaxError
|
type: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
!!!
|
!!!
|
||||||
|
|
|
@ -9,4 +9,6 @@ negative:
|
||||||
phase: early
|
phase: early
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
!!!
|
!!!
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
^ expected errors | v input
|
||||||
|
// Copyright (C) 2019 Leo Balter. 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: parse
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
!!!
|
|
@ -0,0 +1,15 @@
|
||||||
|
NEGATIVE
|
||||||
|
^ expected errors | v input
|
||||||
|
// Copyright (C) 2019 Leo Balter. 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: parse
|
||||||
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated!";
|
||||||
|
|
||||||
|
!!!
|
|
@ -10,6 +10,6 @@ negative:
|
||||||
phase: parse
|
phase: parse
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated!";
|
$DONOTEVALUATE(1);
|
||||||
|
|
||||||
!!!
|
!!!
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
^ expected errors | v input
|
||||||
|
// Copyright (C) 2019 Leo Balter. 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: parse
|
||||||
|
flags: [raw]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
|
!!!
|
|
@ -0,0 +1,16 @@
|
||||||
|
NEGATIVE
|
||||||
|
^ expected errors | v input
|
||||||
|
// Copyright (C) 2019 Leo Balter. 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: parse
|
||||||
|
flags: [raw]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
!!!
|
|
@ -11,6 +11,6 @@ negative:
|
||||||
phase: resolution
|
phase: resolution
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated!";
|
$DONOTEVALUATE(1);
|
||||||
|
|
||||||
import 'non-existent-module.js';
|
import 'non-existent-module.js';
|
||||||
|
|
Loading…
Reference in New Issue