Linter should require direct throw statement for raw tests instead of DONOTEVALUATE

This commit is contained in:
Leo Balter 2019-02-05 15:32:34 -05:00 committed by Rick Waldron
parent f13a0c5aaf
commit 8e0c0eac10
9 changed files with 76 additions and 4 deletions

View File

@ -5,6 +5,10 @@ _THROW_STMT = re.compile(
r'^\$DONOTEVALUATE\(\);$',
re.MULTILINE)
_THROW_STMT_LEGACY = re.compile(
r'^throw "Test262: This statement should not be evaluated\.";$',
re.MULTILINE)
class CheckNegative(Check):
'''Ensure tests have the expected YAML-formatted metadata.'''
ID = 'NEGATIVE'
@ -23,5 +27,9 @@ class CheckNegative(Check):
if not 'phase' in negative:
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"]:
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'

View File

@ -9,4 +9,6 @@ negative:
type: SyntaxError
---*/
$DONOTEVALUATE();
!!!

View File

@ -9,4 +9,6 @@ negative:
phase: early
---*/
$DONOTEVALUATE();
!!!

View File

@ -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();
!!!

View File

@ -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!";
!!!

View File

@ -10,6 +10,6 @@ negative:
phase: parse
---*/
throw "Test262: This statement should not be evaluated!";
$DONOTEVALUATE(1);
!!!

View File

@ -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.";
!!!

View File

@ -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();
!!!

View File

@ -11,6 +11,6 @@ negative:
phase: resolution
---*/
throw "Test262: This statement should not be evaluated!";
$DONOTEVALUATE(1);
import 'non-existent-module.js';