| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:analyzer_experimental/analyzer.dart'; | 5 import 'package:analyzer/analyzer.dart'; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 | 7 |
| 8 void main() { | 8 void main() { |
| 9 test("parses a valid compilation unit successfully", () { | 9 test("parses a valid compilation unit successfully", () { |
| 10 var unit = parseCompilationUnit("void main() => print('Hello, world!');"); | 10 var unit = parseCompilationUnit("void main() => print('Hello, world!');"); |
| 11 expect(unit.toString(), equals("void main() => print('Hello, world!');")); | 11 expect(unit.toString(), equals("void main() => print('Hello, world!');")); |
| 12 }); | 12 }); |
| 13 | 13 |
| 14 test("throws errors for an invalid compilation unit", () { | 14 test("throws errors for an invalid compilation unit", () { |
| 15 expect(() { | 15 expect(() { |
| 16 parseCompilationUnit("void main() => print('Hello, world!')", | 16 parseCompilationUnit("void main() => print('Hello, world!')", |
| 17 name: 'test.dart'); | 17 name: 'test.dart'); |
| 18 }, throwsA(predicate((error) { | 18 }, throwsA(predicate((error) { |
| 19 return error is AnalyzerErrorGroup && | 19 return error is AnalyzerErrorGroup && |
| 20 error.toString().contains("line 1 of test.dart"); | 20 error.toString().contains("line 1 of test.dart"); |
| 21 }))); | 21 }))); |
| 22 }); | 22 }); |
| 23 | 23 |
| 24 test("defaults to '<unknown source>' if no name is provided", () { | 24 test("defaults to '<unknown source>' if no name is provided", () { |
| 25 expect(() { | 25 expect(() { |
| 26 parseCompilationUnit("void main() => print('Hello, world!')"); | 26 parseCompilationUnit("void main() => print('Hello, world!')"); |
| 27 }, throwsA(predicate((error) { | 27 }, throwsA(predicate((error) { |
| 28 return error is AnalyzerErrorGroup && | 28 return error is AnalyzerErrorGroup && |
| 29 error.toString().contains("line 1 of <unknown source>"); | 29 error.toString().contains("line 1 of <unknown source>"); |
| 30 }))); | 30 }))); |
| 31 }); | 31 }); |
| 32 } | 32 } |
| OLD | NEW |