OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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:test/test.dart'; | 5 import 'package:test/test.dart'; |
6 import 'package:source_span/source_span.dart'; | 6 import 'package:source_span/source_span.dart'; |
7 import 'package:source_span/src/colors.dart' as colors; | 7 import 'package:source_span/src/colors.dart' as colors; |
8 | 8 |
9 main() { | 9 main() { |
10 var file; | 10 var file; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 ^""")); | 52 ^""")); |
53 }); | 53 }); |
54 | 54 |
55 test("works for a point span at the end of the file", () { | 55 test("works for a point span at the end of the file", () { |
56 expect(file.location(38).pointSpan().message("oh no"), equals(""" | 56 expect(file.location(38).pointSpan().message("oh no"), equals(""" |
57 line 3, column 12 of foo.dart: oh no | 57 line 3, column 12 of foo.dart: oh no |
58 zip zap zop | 58 zip zap zop |
59 ^""")); | 59 ^""")); |
60 }); | 60 }); |
61 | 61 |
| 62 test("works for a point span at the end of the file with no trailing newline", |
| 63 () { |
| 64 file = new SourceFile("zip zap zop"); |
| 65 expect(file.location(11).pointSpan().message("oh no"), equals(""" |
| 66 line 1, column 12: oh no |
| 67 zip zap zop |
| 68 ^""")); |
| 69 }); |
| 70 |
62 test("works for a point span in an empty file", () { | 71 test("works for a point span in an empty file", () { |
63 expect(new SourceFile("").location(0).pointSpan().message("oh no"), | 72 expect(new SourceFile("").location(0).pointSpan().message("oh no"), |
64 equals(""" | 73 equals(""" |
65 line 1, column 1: oh no | 74 line 1, column 1: oh no |
66 | 75 |
67 ^""")); | 76 ^""")); |
68 }); | 77 }); |
69 | 78 |
70 test("works for a single-line file without a newline", () { | 79 test("works for a single-line file without a newline", () { |
71 expect(new SourceFile("foo bar").span(0, 7).message("oh no"), | 80 expect(new SourceFile("foo bar").span(0, 7).message("oh no"), |
(...skipping 19 matching lines...) Expand all Loading... |
91 }); | 100 }); |
92 | 101 |
93 test("uses the given color if it's passed", () { | 102 test("uses the given color if it's passed", () { |
94 expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals(""" | 103 expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals(""" |
95 line 1, column 5 of foo.dart: oh no | 104 line 1, column 5 of foo.dart: oh no |
96 foo ${colors.YELLOW}bar${colors.NONE} baz | 105 foo ${colors.YELLOW}bar${colors.NONE} baz |
97 ${colors.YELLOW}^^^${colors.NONE}""")); | 106 ${colors.YELLOW}^^^${colors.NONE}""")); |
98 }); | 107 }); |
99 }); | 108 }); |
100 } | 109 } |
OLD | NEW |