diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart new file mode 100644 index 00000000000..6163277faf9 --- /dev/null +++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart @@ -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: ' }'); + } +} diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart new file mode 100644 index 00000000000..b5329c3ae4d --- /dev/null +++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart @@ -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: ' }'); + } +} diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart new file mode 100644 index 00000000000..47cd0c033d3 --- /dev/null +++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart @@ -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: ' }'); + } +} diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart new file mode 100644 index 00000000000..f00655b4e01 --- /dev/null +++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart @@ -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: ' }'); + } +} diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart new file mode 100644 index 00000000000..48fc6b1970f --- /dev/null +++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart @@ -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 allExceptEof = [ + 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); + } +}