| 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 library test.parse.compilation.unit; | 5 library test.parse.compilation.unit; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 }); | 25 }); |
| 26 | 26 |
| 27 test("defaults to '<unknown source>' if no name is provided", () { | 27 test("defaults to '<unknown source>' if no name is provided", () { |
| 28 expect(() { | 28 expect(() { |
| 29 parseCompilationUnit("void main() => print('Hello, world!')"); | 29 parseCompilationUnit("void main() => print('Hello, world!')"); |
| 30 }, throwsA(predicate((error) { | 30 }, throwsA(predicate((error) { |
| 31 return error is AnalyzerErrorGroup && | 31 return error is AnalyzerErrorGroup && |
| 32 error.toString().contains("Error in <unknown source>: Expected to find
';'"); | 32 error.toString().contains("Error in <unknown source>: Expected to find
';'"); |
| 33 }))); | 33 }))); |
| 34 }); | 34 }); |
| 35 |
| 36 test("allows you to specify whether or not to parse function bodies", () { |
| 37 var unit = parseCompilationUnit( |
| 38 "void main() => print('Hello, world!');", parseFunctionBodies: false); |
| 39 expect(unit.toString(), equals("void main() ;")); |
| 40 }); |
| 35 } | 41 } |
| OLD | NEW |