OLD | NEW |
| (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 } | |
OLD | NEW |