| Index: pkg/analyzer_experimental/test/parse_compilation_unit_test.dart
|
| diff --git a/pkg/analyzer_experimental/test/parse_compilation_unit_test.dart b/pkg/analyzer_experimental/test/parse_compilation_unit_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..69389b83ef5674202a65fe4eb6fb7d9c523e5437
|
| --- /dev/null
|
| +++ b/pkg/analyzer_experimental/test/parse_compilation_unit_test.dart
|
| @@ -0,0 +1,32 @@
|
| +// Copyright (c) 2013, 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_experimental/analyzer.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +void main() {
|
| + test("parses a valid compilation unit successfully", () {
|
| + var unit = parseCompilationUnit("void main() => print('Hello, world!');");
|
| + expect(unit.toString(), equals("void main() => print('Hello, world!');"));
|
| + });
|
| +
|
| + test("throws errors for an invalid compilation unit", () {
|
| + expect(() {
|
| + parseCompilationUnit("void main() => print('Hello, world!')",
|
| + name: 'test.dart');
|
| + }, throwsA(predicate((error) {
|
| + return error is AnalyzerErrorGroup &&
|
| + error.toString().contains("line 1 of test.dart");
|
| + })));
|
| + });
|
| +
|
| + test("defaults to '<unknown source>' if no name is provided", () {
|
| + expect(() {
|
| + parseCompilationUnit("void main() => print('Hello, world!')");
|
| + }, throwsA(predicate((error) {
|
| + return error is AnalyzerErrorGroup &&
|
| + error.toString().contains("line 1 of <unknown source>");
|
| + })));
|
| + });
|
| +}
|
|
|