| OLD | NEW |
| 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.integration.analysis.occurrences; | 5 library test.integration.analysis.occurrences; |
| 6 | 6 |
| 7 import '../../reflective_tests.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import '../../reflective_tests.dart'; |
| 10 import '../integration_tests.dart'; | 11 import '../integration_tests.dart'; |
| 11 | 12 |
| 12 @ReflectiveTestCase() | 13 @ReflectiveTestCase() |
| 13 class Test extends AbstractAnalysisServerIntegrationTest { | 14 class Test extends AbstractAnalysisServerIntegrationTest { |
| 14 test_occurrences() { | 15 test_occurrences() { |
| 15 String pathname = sourcePath('test.dart'); | 16 String pathname = sourcePath('test.dart'); |
| 16 String text = | 17 String text = |
| 17 r''' | 18 r''' |
| 18 main() { | 19 main() { |
| 19 int sum = 0; | 20 int sum = 0; |
| 20 for (int i = 0; i < 10; i++) { | 21 for (int i = 0; i < 10; i++) { |
| 21 for (int j = 0; j < i; j++) { | 22 for (int j = 0; j < i; j++) { |
| 22 sum += j; | 23 sum += j; |
| 23 } | 24 } |
| 24 } | 25 } |
| 25 print(sum); | 26 print(sum); |
| 26 } | 27 } |
| 27 '''; | 28 '''; |
| 28 writeFile(pathname, text); | 29 writeFile(pathname, text); |
| 29 standardAnalysisSetup(); | 30 standardAnalysisSetup(); |
| 30 sendAnalysisSetSubscriptions({ | 31 sendAnalysisSetSubscriptions({ |
| 31 'OCCURRENCES': [pathname] | 32 AnalysisService.OCCURRENCES: [pathname] |
| 32 }); | 33 }); |
| 33 List occurrences; | 34 List occurrences; |
| 34 onAnalysisOccurrences.listen((params) { | 35 onAnalysisOccurrences.listen((params) { |
| 35 expect(params['file'], equals(pathname)); | 36 expect(params['file'], equals(pathname)); |
| 36 occurrences = params['occurrences']; | 37 occurrences = params['occurrences']; |
| 37 }); | 38 }); |
| 38 return analysisFinished.then((_) { | 39 return analysisFinished.then((_) { |
| 39 expect(currentAnalysisErrors[pathname], isEmpty); | 40 expect(currentAnalysisErrors[pathname], isEmpty); |
| 40 Set<int> findOffsets(String elementName) { | 41 Set<int> findOffsets(String elementName) { |
| 41 for (Map occurrence in occurrences) { | 42 for (Map occurrence in occurrences) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 55 check('i', ['i = 0', 'i < 10', 'i++', 'i;']); | 56 check('i', ['i = 0', 'i < 10', 'i++', 'i;']); |
| 56 check('j', ['j = 0', 'j < i', 'j++', 'j;']); | 57 check('j', ['j = 0', 'j < i', 'j++', 'j;']); |
| 57 check('sum', ['sum = 0', 'sum +=', 'sum)']); | 58 check('sum', ['sum = 0', 'sum +=', 'sum)']); |
| 58 }); | 59 }); |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 | 62 |
| 62 main() { | 63 main() { |
| 63 runReflectiveTests(Test); | 64 runReflectiveTests(Test); |
| 64 } | 65 } |
| OLD | NEW |