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

Side by Side Diff: pkg/analysis_server/test/completion_test_support.dart

Issue 787863003: Make completion tests handle exceptions during getSuggestions(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
« 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.completion.support; 5 library test.completion.support;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return; 58 return;
59 if (suggestions.any( 59 if (suggestions.any(
60 (CompletionSuggestion suggestion) => suggestion.completion == completion )) { 60 (CompletionSuggestion suggestion) => suggestion.completion == completion )) {
61 fail( 61 fail(
62 "Did not expect completion '$completion' but found:\n $suggestedCompl etions"); 62 "Did not expect completion '$completion' but found:\n $suggestedCompl etions");
63 } 63 }
64 } 64 }
65 65
66 runTest(LocationSpec spec, [Map<String, String> extraFiles]) { 66 runTest(LocationSpec spec, [Map<String, String> extraFiles]) {
67 super.setUp(); 67 super.setUp();
68 String content = spec.source; 68 return new Future(() {
69 addFile(testFile, content); 69 String content = spec.source;
70 this.testCode = content; 70 addFile(testFile, content);
71 completionOffset = spec.testLocation; 71 this.testCode = content;
72 if (extraFiles != null) { 72 completionOffset = spec.testLocation;
73 extraFiles.forEach((String fileName, String content) { 73 if (extraFiles != null) {
74 addFile(fileName, content); 74 extraFiles.forEach((String fileName, String content) {
75 }); 75 addFile(fileName, content);
76 } 76 });
77 return getSuggestions().then((_) {
78 try {
79 //expect(replacementOffset, equals(completionOffset));
80 //expect(replacementLength, equals(0));
81 for (String result in spec.positiveResults) {
82 assertHasCompletion(result);
83 }
84 for (String result in spec.negativeResults) {
85 assertHasNoCompletion(result);
86 }
87 } finally {
88 super.tearDown();
89 } 77 }
78 }).then((_) => getSuggestions()).then((_) {
79 //expect(replacementOffset, equals(completionOffset));
80 //expect(replacementLength, equals(0));
81 for (String result in spec.positiveResults) {
82 assertHasCompletion(result);
83 }
84 for (String result in spec.negativeResults) {
85 assertHasNoCompletion(result);
86 }
87 }).whenComplete(() {
88 super.tearDown();
90 }); 89 });
91 } 90 }
92 91
93 /** 92 /**
94 * Generate a set of completion tests based on the given [originalSource]. 93 * Generate a set of completion tests based on the given [originalSource].
95 * 94 *
96 * The source string has completion points embedded in it, which are 95 * The source string has completion points embedded in it, which are
97 * identified by '!X' where X is a single character. Each X is matched to 96 * identified by '!X' where X is a single character. Each X is matched to
98 * positive or negative results in the array of [validationStrings]. 97 * positive or negative results in the array of [validationStrings].
99 * Validation strings contain the name of a prediction with a two character 98 * Validation strings contain the name of a prediction with a two character
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 err 255 err
257 ..write(' ') 256 ..write(' ')
258 ..write(ch); 257 ..write(ch);
259 } 258 }
260 } 259 }
261 throw new IllegalStateException(err.toString()); 260 throw new IllegalStateException(err.toString());
262 } 261 }
263 return tests.values.toList(); 262 return tests.values.toList();
264 } 263 }
265 } 264 }
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