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

Side by Side Diff: pkg/analysis_server/test/search/search_result_test.dart

Issue 392693002: Initial implementation for 'search.findElementReferences'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comments Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.search.search_result;
6
7 import 'package:analysis_server/src/computer/element.dart';
8 import 'package:analysis_server/src/constants.dart';
9 import 'package:analysis_server/src/search/search_result.dart';
10 import 'package:analysis_services/search/search_engine.dart';
11 import 'package:analysis_testing/reflective_tests.dart';
12 import 'package:unittest/unittest.dart';
13
14
15 main() {
16 groupSep = ' | ';
17 group('SearchResultKind', () {
18 runReflectiveTests(SearchResultTest);
19 runReflectiveTests(SearchResultKindTest);
20 });
21 }
22
23
24 @ReflectiveTestCase()
25 class SearchResultKindTest {
26 void test_fromEngine() {
27 expect(
28 new SearchResultKind.fromEngine(MatchKind.DECLARATION),
29 SearchResultKind.DECLARATION);
30 expect(
31 new SearchResultKind.fromEngine(MatchKind.READ),
32 SearchResultKind.READ);
33 expect(
34 new SearchResultKind.fromEngine(MatchKind.READ_WRITE),
35 SearchResultKind.READ_WRITE);
36 expect(
37 new SearchResultKind.fromEngine(MatchKind.WRITE),
38 SearchResultKind.WRITE);
39 expect(
40 new SearchResultKind.fromEngine(MatchKind.REFERENCE),
41 SearchResultKind.REFERENCE);
42 expect(
43 new SearchResultKind.fromEngine(MatchKind.INVOCATION),
44 SearchResultKind.INVOCATION);
45 expect(new SearchResultKind.fromEngine(null), SearchResultKind.UNKNOWN);
46 }
47
48 void test_fromName() {
49 expect(
50 new SearchResultKind.fromName(SearchResultKind.DECLARATION.name),
51 SearchResultKind.DECLARATION);
52 expect(
53 new SearchResultKind.fromName(SearchResultKind.READ.name),
54 SearchResultKind.READ);
55 expect(
56 new SearchResultKind.fromName(SearchResultKind.READ_WRITE.name),
57 SearchResultKind.READ_WRITE);
58 expect(
59 new SearchResultKind.fromName(SearchResultKind.WRITE.name),
60 SearchResultKind.WRITE);
61 expect(
62 new SearchResultKind.fromName(SearchResultKind.REFERENCE.name),
63 SearchResultKind.REFERENCE);
64 expect(
65 new SearchResultKind.fromName(SearchResultKind.INVOCATION.name),
66 SearchResultKind.INVOCATION);
67 expect(new SearchResultKind.fromName(null), SearchResultKind.UNKNOWN);
68 }
69
70 void test_toString() {
71 expect(SearchResultKind.DECLARATION.toString(), 'DECLARATION');
72 }
73 }
74
75
76 @ReflectiveTestCase()
77 class SearchResultTest {
78 void test_fromJson() {
79 Map<String, Object> map = {
80 KIND: 'READ',
81 IS_POTENTIAL: true,
82 LOCATION: {
83 FILE: '/test.dart',
84 OFFSET: 1,
85 LENGTH: 2,
86 START_LINE: 3,
87 START_COLUMN: 4
88 },
89 PATH: [
90 new Element(
91 ElementKind.FIELD,
92 'myField',
93 new Location('/lib.dart', 10, 20, 30, 40),
94 false,
95 false).toJson()]
96 };
97 SearchResult result = new SearchResult.fromJson(map);
98 expect(result.kind, SearchResultKind.READ);
99 expect(result.location.file, '/test.dart');
100 expect(result.location.offset, 1);
101 expect(result.location.length, 2);
102 expect(result.location.startLine, 3);
103 expect(result.location.startColumn, 4);
104 expect(result.path, hasLength(1));
105 expect(result.path[0].kind, ElementKind.FIELD);
106 expect(result.path[0].name, 'myField');
107 expect(result.path[0].location.file, '/lib.dart');
108 expect(result.path[0].location.offset, 10);
109 // touch toJson();
110 expect(result.toJson(), hasLength(4));
111 // touch asJson();
112 expect(SearchResult.asJson(result), hasLength(4));
113 // touch toString();
114 expect(result.toString(), hasLength(greaterThan(10)));
115 }
116 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/search/search_domain_test.dart ('k') | pkg/analysis_server/test/search/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698