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