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

Side by Side Diff: pkg/analyzer_experimental/test/parse_compilation_unit_test.dart

Issue 22865035: Add a parseDartString method to pkg/analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer_experimental/lib/src/string_source.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'package:analyzer_experimental/analyzer.dart';
6 import 'package:unittest/unittest.dart';
7
8 void main() {
9 test("parses a valid compilation unit successfully", () {
10 var unit = parseCompilationUnit("void main() => print('Hello, world!');");
11 expect(unit.toString(), equals("void main() => print('Hello, world!');"));
12 });
13
14 test("throws errors for an invalid compilation unit", () {
15 expect(() {
16 parseCompilationUnit("void main() => print('Hello, world!')",
17 name: 'test.dart');
18 }, throwsA(predicate((error) {
19 return error is AnalyzerErrorGroup &&
20 error.toString().contains("line 1 of test.dart");
21 })));
22 });
23
24 test("defaults to '<unknown source>' if no name is provided", () {
25 expect(() {
26 parseCompilationUnit("void main() => print('Hello, world!')");
27 }, throwsA(predicate((error) {
28 return error is AnalyzerErrorGroup &&
29 error.toString().contains("line 1 of <unknown source>");
30 })));
31 });
32 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/string_source.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698