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

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 1434063002: Fix for test - don't depend on the order of errors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test.services.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; 7 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
8 import 'package:analysis_server/plugin/protocol/protocol.dart' 8 import 'package:analysis_server/plugin/protocol/protocol.dart'
9 hide AnalysisError; 9 hide AnalysisError;
10 import 'package:analysis_server/src/services/correction/fix.dart'; 10 import 'package:analysis_server/src/services/correction/fix.dart';
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 void test_addSync_blockFunctionBody() { 329 void test_addSync_blockFunctionBody() {
330 resolveTestUnit(''' 330 resolveTestUnit('''
331 foo() {} 331 foo() {}
332 main() { 332 main() {
333 await foo(); 333 await foo();
334 } 334 }
335 '''); 335 ''');
336 List<AnalysisError> errors = context.computeErrors(testSource); 336 List<AnalysisError> errors = context.computeErrors(testSource);
337 expect(errors, hasLength(2)); 337 expect(errors, hasLength(2));
338 // ParserError: Expected to find ';' 338 String message1 = "Expected to find ';'";
339 { 339 String message2 = "Undefined name 'await'";
340 AnalysisError error = errors[0]; 340 expect(errors.map((e) => e.message), unorderedEquals([message1, message2]));
341 expect(error.message, "Expected to find ';'"); 341 for (AnalysisError error in errors) {
342 List<Fix> fixes = _computeFixes(error); 342 if (error.message == message1) {
343 expect(fixes, isEmpty); 343 List<Fix> fixes = _computeFixes(error);
344 } 344 expect(fixes, isEmpty);
345 // Undefined name 'await' 345 }
346 { 346 if (error.message == message2) {
347 AnalysisError error = errors[1]; 347 List<Fix> fixes = _computeFixes(error);
348 expect(error.message, "Undefined name 'await'"); 348 // has exactly one fix
349 List<Fix> fixes = _computeFixes(error); 349 expect(fixes, hasLength(1));
350 // has exactly one fix 350 Fix fix = fixes[0];
351 expect(fixes, hasLength(1)); 351 expect(fix.kind, DartFixKind.ADD_ASYNC);
352 Fix fix = fixes[0]; 352 // apply to "file"
353 expect(fix.kind, DartFixKind.ADD_ASYNC); 353 List<SourceFileEdit> fileEdits = fix.change.edits;
354 // apply to "file" 354 expect(fileEdits, hasLength(1));
355 List<SourceFileEdit> fileEdits = fix.change.edits; 355 resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits);
356 expect(fileEdits, hasLength(1)); 356 // verify
357 resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits); 357 expect(
358 // verify 358 resultCode,
359 expect( 359 '''
360 resultCode,
361 '''
362 foo() {} 360 foo() {}
363 main() async { 361 main() async {
364 await foo(); 362 await foo();
365 } 363 }
366 '''); 364 ''');
365 }
367 } 366 }
368 } 367 }
369 368
370 void test_addSync_expressionFunctionBody() { 369 void test_addSync_expressionFunctionBody() {
371 errorFilter = (AnalysisError error) { 370 errorFilter = (AnalysisError error) {
372 return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER; 371 return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER;
373 }; 372 };
374 resolveTestUnit(''' 373 resolveTestUnit('''
375 foo() {} 374 foo() {}
376 main() => await foo(); 375 main() => await foo();
(...skipping 4236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4613 int offset = resultCode.indexOf(search); 4612 int offset = resultCode.indexOf(search);
4614 positions.add(new Position(testFile, offset)); 4613 positions.add(new Position(testFile, offset));
4615 } 4614 }
4616 return positions; 4615 return positions;
4617 } 4616 }
4618 4617
4619 void _performAnalysis() { 4618 void _performAnalysis() {
4620 while (context.performAnalysisTask().hasMoreWork); 4619 while (context.performAnalysisTask().hasMoreWork);
4621 } 4620 }
4622 } 4621 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698