OLD | NEW |
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'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 '''.replaceAll('\n ', '\n'), | 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:AssignmentCast*/x; | 31 int y = /*info:AssignmentCast*/x; |
32 } | 32 } |
33 '''.replaceAll('\n ', '\n'), | 33 '''.replaceAll('\n ', '\n'), |
34 }; | 34 }; |
35 testChecker(files); | 35 testChecker(files); |
36 var reporter = new SummaryReporter(); | 36 |
37 testChecker(files, reporter: reporter); | 37 SummaryReporter reporter; |
| 38 testChecker(files, |
| 39 createReporter: (x) => reporter = new SummaryReporter(x)); |
38 | 40 |
39 _verifySummary(GlobalSummary summary) { | 41 _verifySummary(GlobalSummary summary) { |
40 var mainLib = summary.loose['file:///main.dart']; | 42 var mainLib = summary.loose['file:///main.dart']; |
41 expect(mainLib.messages.length, 1); | 43 expect(mainLib.messages.length, 1); |
42 | 44 |
43 var mainMessage = mainLib.messages[0]; | 45 var mainMessage = mainLib.messages[0]; |
44 expect(mainMessage.kind, "StaticTypeError"); | 46 expect(mainMessage.kind, "StaticTypeError"); |
45 expect(mainMessage.level, "severe"); | 47 expect(mainMessage.level, "severe"); |
46 expect(mainMessage.span.text, '"hi"'); | 48 expect(mainMessage.span.text, '"hi"'); |
47 expect( | 49 expect( |
48 mainMessage.span.context, ' x = /*severe:StaticTypeError*/"hi";\n'); | 50 mainMessage.span.context, ' x = /*severe:StaticTypeError*/"hi";\n'); |
49 | 51 |
50 var barLib = summary.packages['foo'].libraries['package:foo/bar.dart']; | 52 var barLib = summary.packages['foo'].libraries['package:foo/bar.dart']; |
51 expect(barLib.messages.length, 1); | 53 expect(barLib.messages.length, 1); |
52 var barMessage = barLib.messages[0]; | 54 var barMessage = barLib.messages[0]; |
53 expect(barMessage.kind, "AssignmentCast"); | 55 expect(barMessage.kind, "AssignmentCast"); |
54 expect(barMessage.level, "info"); | 56 expect(barMessage.level, "info"); |
55 expect(barMessage.span.text, 'x'); | 57 expect(barMessage.span.text, 'x'); |
56 expect(barMessage.span.context, ' int y = /*info:AssignmentCast*/x;\n'); | 58 expect(barMessage.span.context, ' int y = /*info:AssignmentCast*/x;\n'); |
57 } | 59 } |
58 | 60 |
59 var original = reporter.result; | 61 var original = reporter.result; |
60 _verifySummary(original); | 62 _verifySummary(original); |
61 _verifySummary(GlobalSummary.parse(original.toJsonMap())); | 63 _verifySummary(GlobalSummary.parse(original.toJsonMap())); |
62 }); | 64 }); |
63 } | 65 } |
OLD | NEW |