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:test/test.dart'; | 8 import 'package:test/test.dart'; |
9 | 9 |
10 import 'package:dev_compiler/devc.dart'; | 10 import 'package:dev_compiler/devc.dart'; |
11 import 'package:dev_compiler/strong_mode.dart' show StrongModeOptions; | |
12 | 11 |
13 import 'package:dev_compiler/src/analysis_context.dart'; | 12 import 'package:dev_compiler/src/analysis_context.dart'; |
14 import 'package:dev_compiler/src/options.dart'; | 13 import 'package:dev_compiler/src/options.dart'; |
15 import 'package:dev_compiler/src/report.dart'; | 14 import 'package:dev_compiler/src/report.dart'; |
16 import 'package:dev_compiler/src/summary.dart'; | 15 import 'package:dev_compiler/src/summary.dart'; |
17 | 16 |
18 import 'testing.dart'; | 17 import 'testing.dart'; |
19 | 18 |
20 void main() { | 19 void main() { |
21 test('toJson/parse', () { | 20 test('toJson/parse', () { |
22 var files = { | 21 var files = { |
23 '/main.dart': ''' | 22 '/main.dart': ''' |
24 import 'package:foo/bar.dart'; | 23 import 'package:foo/bar.dart'; |
25 | 24 |
26 test1() { | 25 test1() { |
27 x = "hi"; | 26 x = "hi"; |
28 } | 27 } |
29 '''.replaceAll('\n ', '\n'), | 28 '''.replaceAll('\n ', '\n'), |
30 'package:foo/bar.dart': ''' | 29 'package:foo/bar.dart': ''' |
31 List x; | 30 List x; |
32 test2() { | 31 test2() { |
33 List<String> y = x; | 32 List<String> y = x; |
34 } | 33 } |
35 '''.replaceAll('\n ', '\n'), | 34 '''.replaceAll('\n ', '\n'), |
36 }; | 35 }; |
37 | 36 |
38 var provider = createTestResourceProvider(files); | 37 var provider = createTestResourceProvider(files); |
39 var uriResolver = new TestUriResolver(provider); | 38 var uriResolver = new TestUriResolver(provider); |
40 var srcOpts = new SourceResolverOptions(useMockSdk: true); | 39 var srcOpts = new SourceResolverOptions(useMockSdk: true); |
41 var context = createAnalysisContextWithSources( | 40 var context = |
42 new StrongModeOptions(), srcOpts, | 41 createAnalysisContextWithSources(srcOpts, fileResolvers: [uriResolver]); |
43 fileResolvers: [uriResolver]); | |
44 var reporter = new SummaryReporter(context); | 42 var reporter = new SummaryReporter(context); |
45 new BatchCompiler(context, new CompilerOptions(sourceOptions: srcOpts), | 43 new BatchCompiler(context, new CompilerOptions(sourceOptions: srcOpts), |
46 reporter: reporter).compileFromUriString('/main.dart'); | 44 reporter: reporter).compileFromUriString('/main.dart'); |
47 | 45 |
48 _verifySummary(GlobalSummary summary) { | 46 _verifySummary(GlobalSummary summary) { |
49 var mainLib = summary.loose['file:///main.dart']; | 47 var mainLib = summary.loose['file:///main.dart']; |
50 expect(mainLib.messages.length, 2); | 48 expect(mainLib.messages.length, 2); |
51 var analyzerMsg = mainLib.messages[0]; | 49 var analyzerMsg = mainLib.messages[0]; |
52 expect(analyzerMsg.kind, "AnalyzerMessage"); | 50 expect(analyzerMsg.kind, "AnalyzerMessage"); |
53 | 51 |
(...skipping 10 matching lines...) Expand all Loading... |
64 expect(barMessage.level, "warning"); | 62 expect(barMessage.level, "warning"); |
65 expect(barMessage.span.text, 'x'); | 63 expect(barMessage.span.text, 'x'); |
66 expect(barMessage.span.context, ' List<String> y = x;\n'); | 64 expect(barMessage.span.context, ' List<String> y = x;\n'); |
67 } | 65 } |
68 | 66 |
69 var original = reporter.result; | 67 var original = reporter.result; |
70 _verifySummary(original); | 68 _verifySummary(original); |
71 _verifySummary(GlobalSummary.parse(original.toJsonMap())); | 69 _verifySummary(GlobalSummary.parse(original.toJsonMap())); |
72 }); | 70 }); |
73 } | 71 } |
OLD | NEW |