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