OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analysis_server/protocol/protocol_generated.dart'; | 5 import 'package:analysis_server/protocol/protocol_generated.dart'; |
6 import 'package:analysis_server/src/plugin/result_merger.dart'; | 6 import 'package:analysis_server/src/plugin/result_merger.dart'; |
7 import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin; | 7 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
8 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; | 8 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; |
9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
11 | 11 |
12 main() { | 12 main() { |
13 defineReflectiveSuite(() { | 13 defineReflectiveSuite(() { |
14 defineReflectiveTests(ResultMergerTest); | 14 defineReflectiveTests(ResultMergerTest); |
15 }); | 15 }); |
16 } | 16 } |
17 | 17 |
18 @reflectiveTest | 18 @reflectiveTest |
19 class ResultMergerTest { | 19 class ResultMergerTest { |
20 // | 20 // |
21 // The tests in this class should always perform the merge operation twice | 21 // The tests in this class should always perform the merge operation twice |
22 // using the same input values in order to ensure that the input values are | 22 // using the same input values in order to ensure that the input values are |
23 // not modified by the merge operation. | 23 // not modified by the merge operation. |
24 // | 24 // |
25 | 25 |
26 ResultMerger merger = new ResultMerger(); | 26 ResultMerger merger = new ResultMerger(); |
27 | 27 |
28 void test_mergeAnalysisErrorFixes() { | 28 void test_mergeAnalysisErrorFixes() { |
29 plugin.AnalysisError createError(int offset) { | 29 AnalysisError createError(int offset) { |
30 plugin.AnalysisErrorSeverity severity = | 30 AnalysisErrorSeverity severity = AnalysisErrorSeverity.ERROR; |
31 plugin.AnalysisErrorSeverity.ERROR; | 31 AnalysisErrorType type = AnalysisErrorType.HINT; |
32 plugin.AnalysisErrorType type = plugin.AnalysisErrorType.HINT; | 32 Location location = new Location('test.dart', offset, 2, 3, 4); |
33 plugin.Location location = | 33 return new AnalysisError(severity, type, location, '', ''); |
34 new plugin.Location('test.dart', offset, 2, 3, 4); | |
35 return new plugin.AnalysisError(severity, type, location, '', ''); | |
36 } | 34 } |
37 | 35 |
38 plugin.AnalysisError error1 = createError(10); | 36 AnalysisError error1 = createError(10); |
39 plugin.AnalysisError error2 = createError(20); | 37 AnalysisError error2 = createError(20); |
40 plugin.AnalysisError error3 = createError(30); | 38 AnalysisError error3 = createError(30); |
41 plugin.AnalysisError error4 = createError(40); | 39 AnalysisError error4 = createError(40); |
42 plugin.PrioritizedSourceChange change1 = | 40 plugin.PrioritizedSourceChange change1 = |
43 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange('a')); | 41 new plugin.PrioritizedSourceChange(1, new SourceChange('a')); |
44 plugin.PrioritizedSourceChange change2 = | 42 plugin.PrioritizedSourceChange change2 = |
45 new plugin.PrioritizedSourceChange(2, new plugin.SourceChange('b')); | 43 new plugin.PrioritizedSourceChange(2, new SourceChange('b')); |
46 plugin.PrioritizedSourceChange change3 = | 44 plugin.PrioritizedSourceChange change3 = |
47 new plugin.PrioritizedSourceChange(3, new plugin.SourceChange('c')); | 45 new plugin.PrioritizedSourceChange(3, new SourceChange('c')); |
48 plugin.PrioritizedSourceChange change4 = | 46 plugin.PrioritizedSourceChange change4 = |
49 new plugin.PrioritizedSourceChange(4, new plugin.SourceChange('d')); | 47 new plugin.PrioritizedSourceChange(4, new SourceChange('d')); |
50 plugin.PrioritizedSourceChange change5 = | 48 plugin.PrioritizedSourceChange change5 = |
51 new plugin.PrioritizedSourceChange(5, new plugin.SourceChange('e')); | 49 new plugin.PrioritizedSourceChange(5, new SourceChange('e')); |
52 plugin.AnalysisErrorFixes fix1 = | 50 plugin.AnalysisErrorFixes fix1 = |
53 new plugin.AnalysisErrorFixes(error1, fixes: [change1]); | 51 new plugin.AnalysisErrorFixes(error1, fixes: [change1]); |
54 plugin.AnalysisErrorFixes fix2 = | 52 plugin.AnalysisErrorFixes fix2 = |
55 new plugin.AnalysisErrorFixes(error2, fixes: [change2]); | 53 new plugin.AnalysisErrorFixes(error2, fixes: [change2]); |
56 plugin.AnalysisErrorFixes fix3 = | 54 plugin.AnalysisErrorFixes fix3 = |
57 new plugin.AnalysisErrorFixes(error2, fixes: [change3]); | 55 new plugin.AnalysisErrorFixes(error2, fixes: [change3]); |
58 plugin.AnalysisErrorFixes fix4 = | 56 plugin.AnalysisErrorFixes fix4 = |
59 new plugin.AnalysisErrorFixes(error3, fixes: [change4]); | 57 new plugin.AnalysisErrorFixes(error3, fixes: [change4]); |
60 plugin.AnalysisErrorFixes fix5 = | 58 plugin.AnalysisErrorFixes fix5 = |
61 new plugin.AnalysisErrorFixes(error4, fixes: [change5]); | 59 new plugin.AnalysisErrorFixes(error4, fixes: [change5]); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ]), | 339 ]), |
342 unorderedEquals([outline1, outline2and3, outline4])); | 340 unorderedEquals([outline1, outline2and3, outline4])); |
343 } | 341 } |
344 | 342 |
345 runTest(); | 343 runTest(); |
346 runTest(); | 344 runTest(); |
347 } | 345 } |
348 | 346 |
349 void test_mergePrioritizedSourceChanges() { | 347 void test_mergePrioritizedSourceChanges() { |
350 plugin.PrioritizedSourceChange kind1 = | 348 plugin.PrioritizedSourceChange kind1 = |
351 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange('')); | 349 new plugin.PrioritizedSourceChange(1, new SourceChange('')); |
352 plugin.PrioritizedSourceChange kind2 = | 350 plugin.PrioritizedSourceChange kind2 = |
353 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange('')); | 351 new plugin.PrioritizedSourceChange(1, new SourceChange('')); |
354 plugin.PrioritizedSourceChange kind3 = | 352 plugin.PrioritizedSourceChange kind3 = |
355 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange('')); | 353 new plugin.PrioritizedSourceChange(1, new SourceChange('')); |
356 plugin.PrioritizedSourceChange kind4 = | 354 plugin.PrioritizedSourceChange kind4 = |
357 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange('')); | 355 new plugin.PrioritizedSourceChange(1, new SourceChange('')); |
358 | 356 |
359 void runTest() { | 357 void runTest() { |
360 expect( | 358 expect( |
361 merger.mergePrioritizedSourceChanges([ | 359 merger.mergePrioritizedSourceChanges([ |
362 [kind3, kind2], | 360 [kind3, kind2], |
363 [], | 361 [], |
364 [kind4], | 362 [kind4], |
365 [kind1] | 363 [kind1] |
366 ]), | 364 ]), |
367 unorderedEquals([kind1, kind2, kind3, kind4])); | 365 unorderedEquals([kind1, kind2, kind3, kind4])); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 729 } |
732 | 730 |
733 void test_overlaps_true_onLeft() { | 731 void test_overlaps_true_onLeft() { |
734 expect(merger.overlaps(1, 5, 3, 7), isTrue); | 732 expect(merger.overlaps(1, 5, 3, 7), isTrue); |
735 } | 733 } |
736 | 734 |
737 void test_overlaps_true_onRight() { | 735 void test_overlaps_true_onRight() { |
738 expect(merger.overlaps(3, 7, 1, 5), isTrue); | 736 expect(merger.overlaps(3, 7, 1, 5), isTrue); |
739 } | 737 } |
740 } | 738 } |
OLD | NEW |