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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.parse.compilation.unit;
6
7 import 'package:analyzer/analyzer.dart';
8 import 'package:unittest/unittest.dart';
9
10 import 'utils.dart';
11
12 void main() {
13 initializeTestEnvironment();
14 test("parses a valid compilation unit successfully", () {
15 var unit = parseCompilationUnit("void main() => print('Hello, world!');");
16 expect(unit.toString(), equals("void main() => print('Hello, world!');"));
17 });
18
19 test("throws errors for an invalid compilation unit", () {
20 expect(() {
21 parseCompilationUnit("void main() => print('Hello, world!')",
22 name: 'test.dart');
23 }, throwsA(predicate((error) {
24 return error is AnalyzerErrorGroup &&
25 error.toString().contains("Error in test.dart: Expected to find ';'");
26 })));
27 });
28
29 test("defaults to '<unknown source>' if no name is provided", () {
30 expect(() {
31 parseCompilationUnit("void main() => print('Hello, world!')");
32 }, throwsA(predicate((error) {
33 return error is AnalyzerErrorGroup &&
34 error
35 .toString()
36 .contains("Error in <unknown source>: Expected to find ';'");
37 })));
38 });
39
40 test("allows you to specify whether or not to parse function bodies", () {
41 var unit = parseCompilationUnit("void main() => print('Hello, world!');",
42 parseFunctionBodies: false);
43 expect(unit.toString(), equals("void main();"));
44 });
45 }
OLDNEW
« 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