Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(897)

Unified Diff: packages/analyzer/test/parse_compilation_unit_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/analyzer/test/instrumentation/test_all.dart ('k') | packages/analyzer/test/reflective_tests.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/analyzer/test/parse_compilation_unit_test.dart
diff --git a/packages/analyzer/test/parse_compilation_unit_test.dart b/packages/analyzer/test/parse_compilation_unit_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..71e4838d1af07b89d1b08e50fbc15c2281a13263
--- /dev/null
+++ b/packages/analyzer/test/parse_compilation_unit_test.dart
@@ -0,0 +1,45 @@
+// 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.
+
+library test.parse.compilation.unit;
+
+import 'package:analyzer/analyzer.dart';
+import 'package:unittest/unittest.dart';
+
+import 'utils.dart';
+
+void main() {
+ initializeTestEnvironment();
+ 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("Error in test.dart: Expected to find ';'");
+ })));
+ });
+
+ 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("Error in <unknown source>: Expected to find ';'");
+ })));
+ });
+
+ test("allows you to specify whether or not to parse function bodies", () {
+ var unit = parseCompilationUnit("void main() => print('Hello, world!');",
+ parseFunctionBodies: false);
+ expect(unit.toString(), equals("void main();"));
+ });
+}
« no previous file with comments | « packages/analyzer/test/instrumentation/test_all.dart ('k') | packages/analyzer/test/reflective_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698