mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 15:04:43 +02:00
Generation: don't make negative parse SyntaxError tests that have flags: [async]. Fixes gh-1229
This commit is contained in:
parent
758b9ec575
commit
95d51c4a15
@ -156,10 +156,20 @@ class Template:
|
|||||||
if len(features):
|
if len(features):
|
||||||
lines += ['features: ' + re.sub('\n\s*', ' ', yaml.dump(features, default_flow_style=True).strip())]
|
lines += ['features: ' + re.sub('\n\s*', ' ', yaml.dump(features, default_flow_style=True).strip())]
|
||||||
|
|
||||||
|
# Reconcile "negative" meta data before "flags"
|
||||||
|
if case_values['meta'].get('negative'):
|
||||||
|
if self.attribs['meta'].get('negative'):
|
||||||
|
raise Exception('Cannot specify negative in case and template file')
|
||||||
|
negative = case_values['meta'].get('negative')
|
||||||
|
else:
|
||||||
|
negative = self.attribs['meta'].get('negative')
|
||||||
|
|
||||||
flags = ['generated']
|
flags = ['generated']
|
||||||
flags += case_values['meta'].get('flags', [])
|
flags += case_values['meta'].get('flags', [])
|
||||||
flags += self.attribs['meta'].get('flags', [])
|
flags += self.attribs['meta'].get('flags', [])
|
||||||
flags = list(OrderedDict.fromkeys(flags))
|
flags = list(OrderedDict.fromkeys(flags))
|
||||||
|
if 'async' in flags and negative and negative.get('phase') == 'parse' and negative.get('type') == 'SyntaxError':
|
||||||
|
flags.remove('async')
|
||||||
lines += ['flags: ' + re.sub('\n\s*', ' ', yaml.dump(flags, default_flow_style=True).strip())]
|
lines += ['flags: ' + re.sub('\n\s*', ' ', yaml.dump(flags, default_flow_style=True).strip())]
|
||||||
|
|
||||||
includes = []
|
includes = []
|
||||||
@ -169,17 +179,9 @@ class Template:
|
|||||||
if len(includes):
|
if len(includes):
|
||||||
lines += ['includes: ' + re.sub('\n\s*', ' ', yaml.dump(includes, default_flow_style=True).strip())]
|
lines += ['includes: ' + re.sub('\n\s*', ' ', yaml.dump(includes, default_flow_style=True).strip())]
|
||||||
|
|
||||||
if case_values['meta'].get('negative'):
|
|
||||||
if self.attribs['meta'].get('negative'):
|
|
||||||
raise Exception('Cannot specify negative in case and template file')
|
|
||||||
negative = case_values['meta'].get('negative')
|
|
||||||
else:
|
|
||||||
negative = self.attribs['meta'].get('negative')
|
|
||||||
|
|
||||||
if negative:
|
if negative:
|
||||||
lines += ['negative:']
|
lines += ['negative:']
|
||||||
as_yaml = yaml.dump(negative,
|
as_yaml = yaml.dump(negative, default_flow_style=False)
|
||||||
default_flow_style=False)
|
|
||||||
lines += indent(as_yaml.strip(), ' ').split('\n')
|
lines += indent(as_yaml.strip(), ' ').split('\n')
|
||||||
|
|
||||||
info = []
|
info = []
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - tools/generation/test/fixtures/async-negative-invalid.case
|
||||||
|
// - tools/generation/test/fixtures/async/async.template
|
||||||
|
/*---
|
||||||
|
description: Early SyntaxError tests should not include "async" in flags[] (async function declaration)
|
||||||
|
esid: prod-AsyncFunctionDeclaration
|
||||||
|
flags: [generated]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
---*/
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
async function fn() {
|
||||||
|
await 1;
|
||||||
|
1=1;
|
||||||
|
}
|
15
tools/generation/test/fixtures/async-negative-invalid.case
vendored
Normal file
15
tools/generation/test/fixtures/async-negative-invalid.case
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Early SyntaxError tests should not include "async" in flags[]
|
||||||
|
template: async
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- setup
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
//- body
|
||||||
|
1=1;
|
13
tools/generation/test/fixtures/async/async.template
vendored
Normal file
13
tools/generation/test/fixtures/async/async.template
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
path: async/async-function-declaration-
|
||||||
|
name: async function declaration
|
||||||
|
esid: prod-AsyncFunctionDeclaration
|
||||||
|
flags: [async]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
async function fn() {
|
||||||
|
await 1;
|
||||||
|
/*{ body }*/
|
||||||
|
}
|
@ -59,6 +59,11 @@ class TestGeneration(unittest.TestCase):
|
|||||||
self.assertEqual(result['returncode'], 0)
|
self.assertEqual(result['returncode'], 0)
|
||||||
self.compareTrees('normal')
|
self.compareTrees('normal')
|
||||||
|
|
||||||
|
def test_async(self):
|
||||||
|
result = self.fixture('async-negative-invalid.case')
|
||||||
|
self.assertEqual(result['returncode'], 0)
|
||||||
|
self.compareTrees('async')
|
||||||
|
|
||||||
def test_negative(self):
|
def test_negative(self):
|
||||||
result = self.fixture('negative.case')
|
result = self.fixture('negative.case')
|
||||||
self.assertEqual(result['returncode'], 0)
|
self.assertEqual(result['returncode'], 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user