Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: pkg/analyzer/test/generated/error_test.dart

Issue 2498133002: Connect analyzer's AnalysisError object to front_end's CompilationError. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698