| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer_cli.test.error; | 5 library analyzer_cli.test.error; |
| 6 | 6 |
| 7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 | 8 |
| 9 import 'utils.dart'; | 9 import 'utils.dart'; |
| 10 | 10 |
| 11 const badDeclaration = 'var int foo;'; |
| 12 const badDeclarationMessage = 'Error in test.dart: ' |
| 13 'Variables can\'t be declared using both \'var\' and a type name.\n'; |
| 14 |
| 11 void main() { | 15 void main() { |
| 12 group('error', () { | 16 group('error', () { |
| 13 test("a valid Dart file doesn't throw any errors", () { | 17 test("a valid Dart file doesn't throw any errors", () { |
| 14 expect(errorsForFile('void main() => print("Hello, world!");'), isNull); | 18 expect(errorsForFile('void main() => print("Hello, world!");'), isNull); |
| 15 }); | 19 }); |
| 16 | 20 |
| 17 test("an empty Dart file doesn't throw any errors", () { | 21 test("an empty Dart file doesn't throw any errors", () { |
| 18 expect(errorsForFile(''), isNull); | 22 expect(errorsForFile(''), isNull); |
| 19 }); | 23 }); |
| 20 | 24 |
| 21 test("an error on the first line", () { | 25 test("an error on the first line", () { |
| 22 expect( | 26 expect(errorsForFile('$badDeclaration\n'), equals(badDeclarationMessage)); |
| 23 errorsForFile('void foo;\n'), | |
| 24 equals( | |
| 25 "Error in test.dart: Variables can't have a type of 'void'.\n")); | |
| 26 }); | 27 }); |
| 27 | 28 |
| 28 test("an error on the last line", () { | 29 test("an error on the last line", () { |
| 29 expect( | 30 expect(errorsForFile('\n$badDeclaration'), equals(badDeclarationMessage)); |
| 30 errorsForFile('\nvoid foo;'), | |
| 31 equals( | |
| 32 "Error in test.dart: Variables can't have a type of 'void'.\n")); | |
| 33 }); | 31 }); |
| 34 | 32 |
| 35 test("an error in the middle", () { | 33 test("an error in the middle", () { |
| 36 expect( | 34 expect( |
| 37 errorsForFile('\nvoid foo;\n'), | 35 errorsForFile('\n$badDeclaration\n'), equals(badDeclarationMessage)); |
| 38 equals( | |
| 39 "Error in test.dart: Variables can't have a type of 'void'.\n")); | |
| 40 }); | 36 }); |
| 41 | 37 |
| 42 var veryLongString = new List.filled(107, ' ').join(''); | 38 var veryLongString = new List.filled(107, ' ').join(''); |
| 43 | 39 |
| 44 test("an error at the end of a very long line", () { | 40 test("an error at the end of a very long line", () { |
| 45 expect( | 41 expect(errorsForFile('$veryLongString $badDeclaration'), |
| 46 errorsForFile('$veryLongString void foo;'), | 42 equals(badDeclarationMessage)); |
| 47 equals( | |
| 48 "Error in test.dart: Variables can't have a type of 'void'.\n")); | |
| 49 }); | 43 }); |
| 50 | 44 |
| 51 test("an error at the beginning of a very long line", () { | 45 test("an error at the beginning of a very long line", () { |
| 52 expect( | 46 expect(errorsForFile('$badDeclaration $veryLongString'), |
| 53 errorsForFile('void foo; $veryLongString'), | 47 equals(badDeclarationMessage)); |
| 54 equals( | |
| 55 "Error in test.dart: Variables can't have a type of 'void'.\n")); | |
| 56 }); | 48 }); |
| 57 | 49 |
| 58 test("an error in the middle of a very long line", () { | 50 test("an error in the middle of a very long line", () { |
| 59 expect( | 51 expect(errorsForFile('$veryLongString $badDeclaration$veryLongString'), |
| 60 errorsForFile('$veryLongString void foo;$veryLongString'), | 52 equals(badDeclarationMessage)); |
| 61 equals( | |
| 62 "Error in test.dart: Variables can't have a type of 'void'.\n")); | |
| 63 }); | 53 }); |
| 64 }); | 54 }); |
| 65 } | 55 } |
| OLD | NEW |