OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 import 'package:analyzer/error/error.dart'; |
| 6 import 'package:analyzer/src/generated/source.dart'; |
| 7 import 'package:analyzer/src/string_source.dart'; |
| 8 import 'package:front_end/src/scanner/errors.dart'; |
| 9 import 'package:source_span/src/span.dart'; |
| 10 import 'package:test/test.dart'; |
| 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 12 |
| 13 main() { |
| 14 defineReflectiveSuite(() { |
| 15 defineReflectiveTests(AnalysisErrorTest); |
| 16 }); |
| 17 } |
| 18 |
| 19 @reflectiveTest |
| 20 class AnalysisErrorTest { |
| 21 void test_location() { |
| 22 String text = ''' |
| 23 line one |
| 24 line two |
| 25 line three |
| 26 line four |
| 27 '''; |
| 28 String path = '/source.dart'; |
| 29 Source source = new StringSource(text, path); |
| 30 int offset = text.indexOf('thr'); |
| 31 int length = 3; |
| 32 ErrorCode errorCode = ScannerErrorCode.UNTERMINATED_STRING_LITERAL; |
| 33 AnalysisError error = new AnalysisError(source, offset, length, errorCode); |
| 34 SourceSpan span = error.span; |
| 35 expect(span.start.line, 2); |
| 36 expect(span.start.column, 5); |
| 37 expect(span.start.offset, offset); |
| 38 expect(span.end.line, 2); |
| 39 expect(span.end.column, 8); |
| 40 expect(span.end.offset, offset + length); |
| 41 expect(span.text, 'thr'); |
| 42 expect(span.sourceUrl, new Uri.file(path)); |
| 43 } |
| 44 } |
OLD | NEW |