OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, 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 dartdoc_search_test; | |
6 | |
7 // TODO(rnystrom): Use "package:" URL (#4968). | |
8 import '../../../../../pkg/expect/lib/expect.dart'; | |
9 import '../lib/src/dartdoc/nav.dart'; | |
10 import '../lib/src/client/search.dart'; | |
11 | |
12 const String URL = 'dummy-url'; | |
13 | |
14 testTopLevelVsMembers() { | |
15 var search = new SearchText('timer'); | |
16 var match = obtainMatch(search, 'timer'); | |
17 // Matching a top-level field 'timer'; | |
18 var topLevelResult = new Result(match, FIELD, URL); | |
19 // Matching a member field 'timer' in 'Foo'; | |
20 var memberResult = new Result(match, FIELD, URL, type: 'Foo'); | |
21 Expect.equals(-1, resultComparator(topLevelResult, memberResult), | |
22 "Top level fields should be preferred to member fields"); | |
23 } | |
24 | |
25 testTopLevelFullVsPrefix() { | |
26 var search = new SearchText('cancel'); | |
27 var fullMatch = obtainMatch(search, 'cancel'); | |
28 var prefixMatch = obtainMatch(search, 'cancelable'); | |
29 // Matching a top-level method 'cancel'; | |
30 var fullResult = new Result(fullMatch, METHOD, URL); | |
31 // Matching a top-level method 'cancelable'; | |
32 var prefixResult = new Result(prefixMatch, METHOD, URL); | |
33 Expect.equals(-1, resultComparator(fullResult, prefixResult), | |
34 "Full matches should be preferred to prefix matches"); | |
35 } | |
36 | |
37 testMemberFullVsPrefix() { | |
38 var search = new SearchText('cancel'); | |
39 var fullMatch = obtainMatch(search, 'cancel'); | |
40 var prefixMatch = obtainMatch(search, 'cancelable'); | |
41 // Matching a member method 'cancel' in 'Isolate'; | |
42 var fullResult = new Result(fullMatch, METHOD, URL, type: 'Isolate'); | |
43 // Matching a member field 'cancelable' in 'Event'; | |
44 var prefixResult = new Result(prefixMatch, FIELD, URL, type: 'Event'); | |
45 Expect.equals(-1, resultComparator(fullResult, prefixResult), | |
46 "Full matches should be preferred to prefix matches"); | |
47 } | |
48 | |
49 void main() { | |
50 testTopLevelVsMembers(); | |
51 testTopLevelFullVsPrefix(); | |
52 testMemberFullVsPrefix(); | |
53 } | |
OLD | NEW |