Chromium Code Reviews| Index: pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart |
| diff --git a/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart b/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart |
| index 1b99cfed2f6992a0819587c184cf7ad930e2e456..9f2f70ece580727b4eacb2d5f0df01b49404523b 100644 |
| --- a/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart |
| +++ b/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart |
| @@ -130,6 +130,132 @@ main() { |
| (s) => s.indexOf('while (') + 'while ('.length); |
| } |
| + test_completeForEmptyCond() async { |
|
Brian Wilkerson
2017/04/18 17:28:50
Just a suggestion: you could put each statement ki
messick
2017/04/18 18:05:52
Good idea, thanks.
messick
2017/04/18 21:35:40
Done.
|
| + await _prepareCompletion( |
| + '}', |
| + ''' |
| +main() { |
| + for (int i = 0;) { |
| + } |
| +} |
| +''', |
| + atEnd: true); |
| + _assertHasChange( |
| + 'Complete for-statement', |
| + ''' |
| +main() { |
| + for (int i = 0; ) { |
|
Brian Wilkerson
2017/04/18 17:28:50
Not knowing exactly how this is suppose to work, I
messick
2017/04/18 18:05:52
I considered that. Two factors dissuaded me. Doing
|
| + } |
| +} |
| +''', |
| + (s) => s.indexOf('0; ') + '0; '.length); |
| + } |
| + |
| + test_completeForEmptyInit() async { |
| + await _prepareCompletion( |
| + '}', |
| + ''' |
| +main() { |
| + for () { |
| + } |
| +} |
| +''', |
| + atEnd: true); |
| + _assertHasChange( |
| + 'Complete for-statement', |
| + ''' |
| +main() { |
| + for () { |
|
Brian Wilkerson
2017/04/18 17:28:50
This, on the other hand, looks right, because we d
messick
2017/04/18 18:05:52
Acknowledged.
|
| + } |
| +} |
| +''', |
| + (s) => s.indexOf('for (') + 'for ('.length); |
| + } |
| + |
| + test_completeForEmptyInitEmptyCond() async { |
| + await _prepareCompletion( |
| + '}', |
| + ''' |
| +main() { |
| + for (;/**/) { |
| + } |
| +} |
| +''', |
| + atEnd: true); |
| + _assertHasChange( |
| + 'Complete for-statement', |
| + ''' |
| +main() { |
| + for (;/**/) { |
| + } |
| +} |
| +''', |
| + (s) => s.indexOf('/**/') + '/**/'.length); |
| + } |
| + |
| + test_completeForEmptyParts() async { |
| + await _prepareCompletion( |
| + ';)', |
| + ''' |
| +main() { |
| + for (;;) |
| +} |
| +''', |
| + atEnd: true); |
| + _assertHasChange( |
| + 'Complete for-statement', |
| + ''' |
| +main() { |
| + for (;;) { |
| + //// |
| + } |
| +} |
| +''', |
| + (s) => s.indexOf(' ') + ' '.length); |
| + } |
| + |
| + test_completeForKeywordOnly() async { |
| + await _prepareCompletion( |
| + 'for', |
| + ''' |
| +main() { |
| + for |
| +} |
| +''', |
| + atEnd: true); |
| + _assertHasChange( |
| + 'Complete for-statement', |
| + ''' |
| +main() { |
| + for () { |
| + //// |
| + } |
| +} |
| +''', |
| + (s) => s.indexOf('for (') + 'for ('.length); |
| + } |
| + |
| + test_completeForMissingLeftSep() async { |
| + await _prepareCompletion( |
| + '}', |
| + ''' |
| +main() { |
| + for (int i = 0) { |
| + } |
| +} |
| +''', |
| + atEnd: true); |
| + _assertHasChange( |
| + 'Complete for-statement', |
| + ''' |
| +main() { |
| + for (int i = 0; ) { |
| + } |
| +} |
| +''', |
| + (s) => s.indexOf('0; ') + '0; '.length); |
| + } |
|
Brian Wilkerson
2017/04/18 17:28:50
Add a test for having both an initializer and a co
messick
2017/04/18 18:05:52
Thanks for catching that. I lost track of that bra
messick
2017/04/18 21:35:40
Done.
|
| + |
| test_completeIfAfterCondition_BAD() async { |
| // TODO(messick): Fix the code to make this like test_completeIfWithCondition. |
| // Recap: Finding the node at the selectionOffset returns the block, not the |