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