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