| 21 | | sub do_search { |
| 22 | | my %params = @_; |
| | 24 | search_ok { ability => 'Drizzle' }, |
| | 25 | [qw/ 382 /], |
| | 26 | "Only Kyogre has Drizzle"; |
| | 27 | |
| | 28 | search_ok { color => 'black', habitat => 'urban' }, |
| | 29 | [qw/ 197 353 354 /], |
| | 30 | "Black urban Pokemon"; |
| | 31 | |
| | 32 | search_ok { name => 'eon', evo_stage => 'base' }, |
| | 33 | [qw/ 352 456 /], |
| | 34 | "The only baseform *eon*s are Kecleon and Finneon"; |
| | 35 | |
| | 36 | search_ok { name => 'char', evo_stage => 'final' }, |
| | 37 | [qw/ 6 /], |
| | 38 | "The only final form *char* is Charizard"; |
| | 39 | |
| | 40 | # Gender dropdown had a few problems at one point, so I gave it several tests |
| | 41 | search_ok { gender => 254, generation => 0 }, |
| | 42 | [qw/ 29 30 31 113 115 124 /], |
| | 43 | "Female-onlys in RBY"; |
| | 44 | |
| | 45 | search_ok { name => 'voltorb', gender => 'not255' }, |
| | 46 | [qw/ /], |
| | 47 | "Voltorb isn't returned by 'any gender'"; |
| | 48 | |
| | 49 | search_ok { name => 'eevee', gender => 255 }, |
| | 50 | [qw/ /], |
| | 51 | "Eevee isn't returned by 'no gender'"; |
| | 52 | |
| | 53 | # Likewise with the breeding; that's gone wrong several times |
| | 54 | search_ok { breed_mode => 'and', breed => [1, 2], evo_stage => 'base' }, |
| | 55 | [qw/ 7 79 131 158 258 /], |
| | 56 | "Families that are Monster/Water 1"; |
| | 57 | |
| | 58 | search_ok { breed_mode => 'and', breed => [13, 13] }, |
| | 59 | [qw/ 132 /], |
| | 60 | "Only Ditto is in the Ditto/Ditto group's'"; |
| | 61 | |
| | 62 | search_ok { breed_mode => 'and', breed => [13, 0] }, |
| | 63 | [qw/ 132 /], |
| | 64 | "Ditto is also returned when searching for Ditto and n/a"; |
| | 65 | |
| | 66 | search_ok { breed_mode => 'and', breed => [13, 5] }, |
| | 67 | [qw/ /], |
| | 68 | "...but not when searching for Ditto and any other group"; |
| | 69 | |
| | 70 | search_ok { |
| | 71 | breed_mode => 'or', |
| | 72 | breed => [9, 11], |
| | 73 | evo_stage => 'base', |
| | 74 | generation => 0, |
| | 75 | }, |
| | 76 | [qw/ 72 88 90 92 98 109 120 138 140 /], |
| | 77 | "RBY families that are Water 3 *or* Indeterminate"; |
| | 78 | |
| | 79 | search_ok { generation => 2, basedex => 3 }, |
| | 80 | [qw/ 265 266 267 268 269 278 279 298 307 308 315 339 340 349 350 358 /], |
| | 81 | "Pokemon from GSC that appear in DP"; |
| | 82 | |
| | 83 | # Types are another common problem area |
| | 84 | search_ok { name => 'eon', type_mode => 'any', type => [qw/ fire /] }, |
| | 85 | [qw/ 5 136 /], |
| | 86 | "Fire *eon*s"; |
| | 87 | |
| | 88 | search_ok { name => 'eon', type_mode => 'any', type => [qw/ fire water /] }, |
| | 89 | [qw/ 5 134 136 395 456 457 /], |
| | 90 | "Fire or water *eon*s"; |
| | 91 | |
| | 92 | search_ok { name => 'eon', type_mode => 'any', type => [qw/ fire water electric /] }, |
| | 93 | [qw/ 5 134 135 136 395 456 457 /], |
| | 94 | "Fire or water or electric *eon*s"; |
| | 95 | |
| | 96 | search_ok { type_mode => 'all', type => [qw/ bug dragon /] }, |
| | 97 | [qw/ /], |
| | 98 | "Bug/dragon Pokemon"; |
| | 99 | |
| | 100 | search_ok { type_mode => 'all', type => [qw/ ghost dragon /] }, |
| | 101 | [qw/ 487 /], |
| | 102 | "Ghost/dragon Pokemon"; |
| | 103 | |
| | 104 | search_ok { type_mode => 'all', type => [qw/ dragon ghost /] }, |
| | 105 | [qw/ 487 /], |
| | 106 | "Dragon/ghost Pokemon (i.e. order doesn't matter)"; |
| | 107 | |
| | 108 | search_ok { type_mode => 'all', type => [qw/ normal flying psychic /] }, |
| | 109 | [qw/ /], |
| | 110 | "Must have three types"; |
| | 111 | |
| | 112 | # Moves have a lot of possibilities; I just try a few here |
| | 113 | search_ok { move => 'judgment' }, |
| | 114 | [qw/ 493 /], |
| | 115 | "Learns Judgment"; |
| | 116 | |
| | 117 | search_ok { move => 'judgment', move_method => [qw/ egg machine tutor /] }, |
| | 118 | [qw/ /], |
| | 119 | "...by leveling up"; |
| | 120 | |
| | 121 | search_ok { move => 'judgment', move_version => [qw/ rb y gs c rusa frlg e /] }, |
| | 122 | [qw/ /], |
| | 123 | "...not in DP"; |
| | 124 | |
| | 125 | search_ok { move => [qw/ splash tackle /], move_version => 'rb' }, |
| | 126 | [qw/ 129 /], |
| | 127 | "Learns Splash and Tackle in RB"; |
| | 128 | |
| | 129 | # Similar for the stats; these all work the same so whatever |
| | 130 | search_ok { stat_hp_lb => 250 }, |
| | 131 | [qw/ 113 242 /], |
| | 132 | "HP stat of 250+"; |
| | 133 | |
| | 134 | # Height and weight had some rounding issues |
| | 135 | search_ok { generation => 1, height_lb => 16, height_ub => 16 }, |
| | 136 | [qw/ 182 183 187 194 220 238 /], |
| | 137 | "GSC Pokemon that are 16\" tall"; |
| | 138 | |
| | 139 | search_ok { height_lb => '0.2m', height_ub => '0.2m' }, |
| | 140 | [qw/ 50 177 298 406 412 433 492 /], |
| | 141 | "Pokemon that are 0.2m tall"; |
| | 142 | |
| | 143 | search_ok { height_lb => '20cm', height_ub => '20cm' }, |
| | 144 | [qw/ 50 177 298 406 412 433 492 /], |
| | 145 | "Pokemon that are 20cm tall (same as above)"; |
| | 146 | |
| | 147 | # Quick sorting checks |
| | 148 | search_ok { name => 'q', sort => 'stat_avg' }, |
| | 149 | [qw/ 155 7 156 284 195 211 416 31 384 /], |
| | 150 | "Sorting by average stat"; |
| | 151 | |
| | 152 | search_ok { name => 'q', sort => 'id', sort_desc => 'on' }, |
| | 153 | [qw/ 416 384 284 211 195 156 155 31 7 /], |
| | 154 | "Reverse sort by id"; |
| | 155 | |
| | 156 | sub search_ok { |
| | 157 | my ($params, $expected, $test_name) = @_; |
| | 158 | |
| | 159 | if (not $params->{sort}) { |
| | 160 | # sort by id for simplicity |
| | 161 | $params->{sort} = 'id'; |
| | 162 | delete $params->{sort_desc}; |
| | 163 | } |
| | 164 | |