More partial code tests

Change-Id: I43416c8d527ca519ad590aab5d2c25c022157f89
Reviewed-on: https://dart-review.googlesource.com/12200
Reviewed-by: Dan Rubel <danrubel@google.com>
This commit is contained in:
Brian Wilkerson 2017-10-09 16:17:45 +00:00
parent c308ac398e
commit f10ff8ae82
5 changed files with 333 additions and 0 deletions

View file

@ -0,0 +1,75 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'partial_code_support.dart';
main() {
new AssertStatementTest().buildAll();
}
class AssertStatementTest extends PartialCodeTest {
buildAll() {
buildTests(
'assert_statement',
[
new TestDescriptor(
'keyword',
'assert',
[
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"assert (_s_);",
allFailing: true),
new TestDescriptor(
'leftParen',
'assert (',
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"assert (_s_);",
allFailing: true),
new TestDescriptor(
'condition',
'assert (a',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
"assert (a);",
allFailing: true),
new TestDescriptor(
'comma',
'assert (a,',
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"assert (a, _s_);",
allFailing: true),
new TestDescriptor(
'message',
'assert (a, b',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
"assert (a, b);",
allFailing: true),
new TestDescriptor(
'trailingComma',
'assert (a, b,',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
"assert (a, b,);",
allFailing: true),
new TestDescriptor('rightParen', 'assert (a, b)',
[ParserErrorCode.EXPECTED_TOKEN], "assert (a, b);",
allFailing: true),
],
PartialCodeTest.statementSuffixes,
head: 'f() { ',
tail: ' }');
}
}

View file

@ -0,0 +1,29 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'partial_code_support.dart';
main() {
new BreakStatementTest().buildAll();
}
class BreakStatementTest extends PartialCodeTest {
buildAll() {
buildTests(
'break_statement',
[
new TestDescriptor(
'keyword', 'break', [ParserErrorCode.EXPECTED_TOKEN], "break;",
allFailing: true),
new TestDescriptor(
'label', 'break a', [ParserErrorCode.EXPECTED_TOKEN], "break a;",
allFailing: true),
],
PartialCodeTest.statementSuffixes,
head: 'f() { ',
tail: ' }');
}
}

View file

@ -0,0 +1,29 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'partial_code_support.dart';
main() {
new ContinueStatementTest().buildAll();
}
class ContinueStatementTest extends PartialCodeTest {
buildAll() {
buildTests(
'continue_statement',
[
new TestDescriptor('keyword', 'continue',
[ParserErrorCode.EXPECTED_TOKEN], "continue;",
allFailing: true),
new TestDescriptor('label', 'continue a',
[ParserErrorCode.EXPECTED_TOKEN], "continue a;",
allFailing: true),
],
PartialCodeTest.statementSuffixes,
head: 'f() { ',
tail: ' }');
}
}

View file

@ -0,0 +1,92 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'partial_code_support.dart';
main() {
new DoStatementTest().buildAll();
}
class DoStatementTest extends PartialCodeTest {
buildAll() {
buildTests(
'do_statement',
[
new TestDescriptor(
'keyword',
'do',
[
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"do {} while (_s_);",
allFailing: true),
new TestDescriptor(
'leftBrace',
'do {',
[
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"do {} while (_s_);",
allFailing: true),
new TestDescriptor(
'rightBrace',
'do {}',
[
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"do {} while (_s_);",
allFailing: true),
new TestDescriptor(
'while',
'do {} while',
[
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"do {} while (_s_);",
allFailing: true),
new TestDescriptor(
'leftParen',
'do {} while (',
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.EXPECTED_TOKEN
],
"do {} while (_s_);",
allFailing: true),
new TestDescriptor(
'condition',
'do {} while (a',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
"do {} while (a);",
allFailing: true),
new TestDescriptor('rightParen', 'do {} while (a)',
[ParserErrorCode.EXPECTED_TOKEN], "do {} while (a);",
allFailing: true),
],
PartialCodeTest.statementSuffixes,
head: 'f() { ',
tail: ' }');
}
}

View file

@ -0,0 +1,108 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'partial_code_support.dart';
main() {
new ExportDirectivesTest().buildAll();
}
class ExportDirectivesTest extends PartialCodeTest {
buildAll() {
List<bool> allExceptEof = <bool>[
false,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true
];
buildTests(
'export_directive',
[
new TestDescriptor(
'keyword',
'export',
[/*ParserErrorCode.MISSING_URI,*/ ParserErrorCode.EXPECTED_TOKEN],
"export '';",
allFailing: true),
new TestDescriptor('emptyUri', "export ''",
[ParserErrorCode.EXPECTED_TOKEN], "export '';"),
new TestDescriptor('uri', "export 'a.dart'",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart';"),
new TestDescriptor(
'hide',
"export 'a.dart' hide",
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
],
"export 'a.dart' hide _s_;",
failing: allExceptEof),
new TestDescriptor('hideName', "export 'a.dart' hide A",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' hide A;"),
new TestDescriptor(
'hideComma',
"export 'a.dart' hide A,",
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
],
"export 'a.dart' hide A, _s_;",
failing: allExceptEof),
new TestDescriptor('hideCommaName', "export 'a.dart' hide A, B",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' hide A, B;"),
new TestDescriptor(
'hideShow',
"export 'a.dart' hide A show",
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
],
"export 'a.dart' hide A show _s_;",
failing: allExceptEof),
new TestDescriptor(
'show',
"export 'a.dart' show",
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
],
"export 'a.dart' show _s_;",
failing: allExceptEof),
new TestDescriptor('showName', "export 'a.dart' show A",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' show A;"),
new TestDescriptor(
'showComma',
"export 'a.dart' show A,",
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
],
"export 'a.dart' show A, _s_;",
failing: allExceptEof),
new TestDescriptor('showCommaName', "export 'a.dart' show A, B",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' show A, B;"),
new TestDescriptor(
'showHide',
"export 'a.dart' show A hide",
[
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
],
"export 'a.dart' show A hide _s_;",
failing: allExceptEof),
],
PartialCodeTest.prePartSuffixes);
}
}