Skip to content
Snippets Groups Projects
Commit 8e0c0eac authored by Leo Balter's avatar Leo Balter Committed by Rick Waldron
Browse files

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

parent f13a0c5a
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,10 @@ _THROW_STMT = re.compile( ...@@ -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): ...@@ -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: ...@@ -9,4 +9,6 @@ negative:
type: SyntaxError type: SyntaxError
---*/ ---*/
$DONOTEVALUATE();
!!! !!!
...@@ -9,4 +9,6 @@ negative: ...@@ -9,4 +9,6 @@ negative:
phase: early phase: early
---*/ ---*/
$DONOTEVALUATE();
!!! !!!
^ 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();
!!!
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: ...@@ -10,6 +10,6 @@ negative:
phase: parse phase: parse
---*/ ---*/
throw "Test262: This statement should not be evaluated!"; $DONOTEVALUATE(1);
!!! !!!
^ 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.";
!!!
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: ...@@ -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';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment