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

Side by Side Diff: test/report_test.dart

Issue 1023893004: Pass through context information in error messages (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 months 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
« no previous file with comments | « test/codegen/expect/server_mode/html_input.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Tests for summary reporting. 5 /// Tests for summary reporting.
6 library dev_compiler.test.report_test; 6 library dev_compiler.test.report_test;
7 7
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'package:dev_compiler/src/testing.dart'; 10 import 'package:dev_compiler/src/testing.dart';
11 import 'package:dev_compiler/src/report.dart'; 11 import 'package:dev_compiler/src/report.dart';
12 import 'package:dev_compiler/src/summary.dart'; 12 import 'package:dev_compiler/src/summary.dart';
13 13
14 import 'test_util.dart'; 14 import 'test_util.dart';
15 15
16 void main() { 16 void main() {
17 configureTest(); 17 configureTest();
18 18
19 test('toJson/parse', () { 19 test('toJson/parse', () {
20 var files = { 20 var files = {
21 '/main.dart': ''' 21 '/main.dart': '''
22 import 'package:foo/bar.dart'; 22 import 'package:foo/bar.dart';
23 23
24 test1() { 24 test1() {
25 x = /*severe:StaticTypeError*/"hi"; 25 x = /*severe:StaticTypeError*/"hi";
26 } 26 }
27 ''', 27 '''.replaceAll('\n ', '\n'),
28 'package:foo/bar.dart': ''' 28 'package:foo/bar.dart': '''
29 num x; 29 num x;
30 test2() { 30 test2() {
31 int y = /*info:DownCast*/x; 31 int y = /*info:DownCast*/x;
32 } 32 }
33 ''', 33 '''.replaceAll('\n ', '\n'),
34 }; 34 };
35 testChecker(files); 35 testChecker(files);
36 var reporter = new SummaryReporter(); 36 var reporter = new SummaryReporter();
37 testChecker(files, reporter: reporter); 37 testChecker(files, reporter: reporter);
38 38
39 var summary1 = reporter.result; 39 _verifySummary(GlobalSummary summary) {
40 expect(summary1.loose['file:///main.dart'].messages.length, 1); 40 var mainLib = summary.loose['file:///main.dart'];
41 var barUrl = 'package:foo/bar.dart'; 41 expect(mainLib.messages.length, 1);
42 expect(summary1.packages['foo'].libraries[barUrl].messages.length, 1);
43 42
44 var summary2 = GlobalSummary.parse(summary1.toJsonMap()); 43 var mainMessage = mainLib.messages[0];
45 expect(summary2.loose['file:///main.dart'].messages.length, 1); 44 expect(mainMessage.kind, "StaticTypeError");
46 expect(summary2.packages['foo'].libraries[barUrl].messages.length, 1); 45 expect(mainMessage.level, "severe");
46 expect(mainMessage.span.text, '"hi"');
47 expect(mainMessage.span.context,
48 ' x = /*severe:StaticTypeError*/"hi";\n');
49
50 var barLib = summary.packages['foo'].libraries['package:foo/bar.dart'];
51 expect(barLib.messages.length, 1);
52 var barMessage = barLib.messages[0];
53 expect(barMessage.kind, "DownCast");
54 expect(barMessage.level, "info");
55 expect(barMessage.span.text, 'x');
56 expect(barMessage.span.context,
57 ' int y = /*info:DownCast*/x;\n');
58 }
59
60 var original = reporter.result;
61 _verifySummary(original);
62 _verifySummary(GlobalSummary.parse(original.toJsonMap()));
47 }); 63 });
48 } 64 }
OLDNEW
« no previous file with comments | « test/codegen/expect/server_mode/html_input.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698