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

Side by Side Diff: pkg/analysis_server/test/src/plugin/result_merger_test.dart

Issue 2683673003: Support merging with priority information (Closed)
Patch Set: Created 3 years, 10 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 | « pkg/analysis_server/lib/src/plugin/result_merger.dart ('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) 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/plugin/protocol/protocol.dart'; 5 import 'package:analysis_server/plugin/protocol/protocol.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/generated_protocol.dart' as plugin;
7 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 10
10 main() { 11 main() {
11 /* 12 /*
12 import 'result_merger_test.dart' as result_merger_test; 13 import 'result_merger_test.dart' as result_merger_test;
13 result_merger_test.main(); 14 result_merger_test.main();
14 */ 15 */
15 defineReflectiveSuite(() { 16 defineReflectiveSuite(() {
16 defineReflectiveTests(ResultMergerTest); 17 defineReflectiveTests(ResultMergerTest);
17 }); 18 });
18 } 19 }
19 20
20 @reflectiveTest 21 @reflectiveTest
21 class ResultMergerTest { 22 class ResultMergerTest {
22 // 23 //
23 // The tests in this class should always perform the merge operation twice 24 // The tests in this class should always perform the merge operation twice
24 // using the same input values in order to ensure that the input values are 25 // using the same input values in order to ensure that the input values are
25 // not modified by the merge operation. 26 // not modified by the merge operation.
26 // 27 //
27 28
28 ResultMerger merger = new ResultMerger(); 29 ResultMerger merger = new ResultMerger();
29 30
30 AnalysisError createError(int offset) { 31 void test_mergeAnalysisErrorFixes() {
31 AnalysisErrorSeverity severity = AnalysisErrorSeverity.ERROR; 32 plugin.AnalysisError createError(int offset) {
32 AnalysisErrorType type = AnalysisErrorType.HINT; 33 plugin.AnalysisErrorSeverity severity =
33 Location location = new Location('test.dart', offset, 2, 3, 4); 34 plugin.AnalysisErrorSeverity.ERROR;
34 return new AnalysisError(severity, type, location, '', ''); 35 plugin.AnalysisErrorType type = plugin.AnalysisErrorType.HINT;
35 } 36 plugin.Location location =
37 new plugin.Location('test.dart', offset, 2, 3, 4);
38 return new plugin.AnalysisError(severity, type, location, '', '');
39 }
36 40
37 void test_mergeAnalysisErrorFixes() { 41 plugin.AnalysisError error1 = createError(10);
38 AnalysisError error1 = createError(10); 42 plugin.AnalysisError error2 = createError(20);
39 AnalysisError error2 = createError(20); 43 plugin.AnalysisError error3 = createError(30);
40 AnalysisError error3 = createError(30); 44 plugin.AnalysisError error4 = createError(40);
41 AnalysisError error4 = createError(40); 45 plugin.PrioritizedSourceChange change1 =
42 SourceChange change1 = new SourceChange('a'); 46 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange('a'));
43 SourceChange change2 = new SourceChange('b'); 47 plugin.PrioritizedSourceChange change2 =
44 SourceChange change3 = new SourceChange('c'); 48 new plugin.PrioritizedSourceChange(2, new plugin.SourceChange('b'));
45 SourceChange change4 = new SourceChange('d'); 49 plugin.PrioritizedSourceChange change3 =
46 SourceChange change5 = new SourceChange('e'); 50 new plugin.PrioritizedSourceChange(3, new plugin.SourceChange('c'));
47 AnalysisErrorFixes fix1 = new AnalysisErrorFixes(error1, fixes: [change1]); 51 plugin.PrioritizedSourceChange change4 =
48 AnalysisErrorFixes fix2 = new AnalysisErrorFixes(error2, fixes: [change2]); 52 new plugin.PrioritizedSourceChange(4, new plugin.SourceChange('d'));
49 AnalysisErrorFixes fix3 = new AnalysisErrorFixes(error2, fixes: [change3]); 53 plugin.PrioritizedSourceChange change5 =
50 AnalysisErrorFixes fix4 = new AnalysisErrorFixes(error3, fixes: [change4]); 54 new plugin.PrioritizedSourceChange(5, new plugin.SourceChange('e'));
51 AnalysisErrorFixes fix5 = new AnalysisErrorFixes(error4, fixes: [change5]); 55 plugin.AnalysisErrorFixes fix1 =
52 AnalysisErrorFixes fix2and3 = 56 new plugin.AnalysisErrorFixes(error1, fixes: [change1]);
53 new AnalysisErrorFixes(error2, fixes: [change2, change3]); 57 plugin.AnalysisErrorFixes fix2 =
58 new plugin.AnalysisErrorFixes(error2, fixes: [change2]);
59 plugin.AnalysisErrorFixes fix3 =
60 new plugin.AnalysisErrorFixes(error2, fixes: [change3]);
61 plugin.AnalysisErrorFixes fix4 =
62 new plugin.AnalysisErrorFixes(error3, fixes: [change4]);
63 plugin.AnalysisErrorFixes fix5 =
64 new plugin.AnalysisErrorFixes(error4, fixes: [change5]);
65 plugin.AnalysisErrorFixes fix2and3 =
66 new plugin.AnalysisErrorFixes(error2, fixes: [change2, change3]);
54 67
55 void runTest() { 68 void runTest() {
56 expect( 69 expect(
57 merger.mergeAnalysisErrorFixes([ 70 merger.mergeAnalysisErrorFixes([
58 [fix1, fix2], 71 [fix1, fix2],
59 [fix3, fix4], 72 [fix3, fix4],
60 [fix5], 73 [fix5],
61 [] 74 []
62 ]), 75 ]),
63 unorderedEquals([fix1, fix2and3, fix4, fix5])); 76 unorderedEquals([fix1, fix2and3, fix4, fix5]));
64 } 77 }
65 78
66 runTest(); 79 runTest();
67 runTest(); 80 runTest();
68 } 81 }
69 82
70 void test_mergeAnalysisErrors() { 83 void test_mergeAnalysisErrors() {
84 AnalysisError createError(int offset) {
85 AnalysisErrorSeverity severity = AnalysisErrorSeverity.ERROR;
86 AnalysisErrorType type = AnalysisErrorType.HINT;
87 Location location = new Location('test.dart', offset, 2, 3, 4);
88 return new AnalysisError(severity, type, location, '', '');
89 }
90
71 AnalysisError error1 = createError(10); 91 AnalysisError error1 = createError(10);
72 AnalysisError error2 = createError(20); 92 AnalysisError error2 = createError(20);
73 AnalysisError error3 = createError(30); 93 AnalysisError error3 = createError(30);
74 AnalysisError error4 = createError(40); 94 AnalysisError error4 = createError(40);
75 95
76 void runTest() { 96 void runTest() {
77 expect( 97 expect(
78 merger.mergeAnalysisErrors([ 98 merger.mergeAnalysisErrors([
79 [error1, error2], 99 [error1, error2],
80 [error3], 100 [error3],
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 [], 342 [],
323 [outline3, outline4] 343 [outline3, outline4]
324 ]), 344 ]),
325 unorderedEquals([outline1, outline2and3, outline4])); 345 unorderedEquals([outline1, outline2and3, outline4]));
326 } 346 }
327 347
328 runTest(); 348 runTest();
329 runTest(); 349 runTest();
330 } 350 }
331 351
352 void test_mergePrioritizedSourceChanges() {
353 plugin.PrioritizedSourceChange kind1 =
354 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange(''));
355 plugin.PrioritizedSourceChange kind2 =
356 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange(''));
357 plugin.PrioritizedSourceChange kind3 =
358 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange(''));
359 plugin.PrioritizedSourceChange kind4 =
360 new plugin.PrioritizedSourceChange(1, new plugin.SourceChange(''));
361
362 void runTest() {
363 expect(
364 merger.mergePrioritizedSourceChanges([
365 [kind3, kind2],
366 [],
367 [kind4],
368 [kind1]
369 ]),
370 unorderedEquals([kind1, kind2, kind3, kind4]));
371 }
372
373 runTest();
374 runTest();
375 }
376
332 void test_mergeRefactoringFeedbacks_convertGetterToMethodFeedback() { 377 void test_mergeRefactoringFeedbacks_convertGetterToMethodFeedback() {
333 RefactoringFeedback feedback1 = new ConvertGetterToMethodFeedback(); 378 RefactoringFeedback feedback1 = new ConvertGetterToMethodFeedback();
334 RefactoringFeedback feedback2 = new ConvertGetterToMethodFeedback(); 379 RefactoringFeedback feedback2 = new ConvertGetterToMethodFeedback();
335 380
336 void runTest() { 381 void runTest() {
337 expect(merger.mergeRefactoringFeedbacks([feedback1, feedback2]), 382 expect(merger.mergeRefactoringFeedbacks([feedback1, feedback2]),
338 equals(feedback1)); 383 equals(feedback1));
339 } 384 }
340 385
341 runTest(); 386 runTest();
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 734 }
690 735
691 void test_overlaps_true_onLeft() { 736 void test_overlaps_true_onLeft() {
692 expect(merger.overlaps(1, 5, 3, 7), isTrue); 737 expect(merger.overlaps(1, 5, 3, 7), isTrue);
693 } 738 }
694 739
695 void test_overlaps_true_onRight() { 740 void test_overlaps_true_onRight() {
696 expect(merger.overlaps(3, 7, 1, 5), isTrue); 741 expect(merger.overlaps(3, 7, 1, 5), isTrue);
697 } 742 }
698 } 743 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/plugin/result_merger.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698