- Timestamp:
- Oct 3, 2009, 10:15:11 AM (16 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 9f5e847
- Parents:
- 340c3e7 (diff), 1167bf1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- t
- Files:
-
- 2 edited
-
completion.t (modified) (8 diffs)
-
mock.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
t/completion.t
rb017b03 r1167bf1 8 8 BEGIN {require (dirname($0) . "/mock.pl");}; 9 9 10 use BarnOwl::Complete::Filter qw(complete_filter_expr); 11 10 12 =head1 DESCRIPTION 11 13 … … 20 22 my $after_point = shift; 21 23 24 my $ctx = BarnOwl::Completion::Context->new($before_point, 25 $after_point); 26 is($ctx->line, $before_point . $after_point); 27 is($ctx->point, length $before_point); 28 29 test_ctx($ctx, @_); 30 } 31 32 sub test_ctx { 33 local $Test::Builder::Level = $Test::Builder::Level + 1; 34 35 my $ctx = shift; 36 22 37 my $words = shift; 23 38 my $word = shift; … … 27 42 my $word_end = shift; 28 43 29 my $ctx = BarnOwl::Completion::Context->new($before_point,30 $after_point);31 32 is($ctx->line, $before_point . $after_point);33 is($ctx->point, length $before_point);34 44 is_deeply($ctx->words, $words); 35 45 if (defined($word)) { … … 41 51 } 42 52 53 sub test_shift { 54 local $Test::Builder::Level = $Test::Builder::Level + 1; 55 56 my $before_point = shift; 57 my $after_point = shift; 58 my $shift = shift; 59 60 my $ctx = BarnOwl::Completion::Context->new($before_point, 61 $after_point); 62 $ctx = $ctx->shift_words($shift); 63 64 test_ctx($ctx, @_); 65 } 66 43 67 44 68 isa_ok(BarnOwl::Completion::Context->new('Hello, W', 'orld'), 'BarnOwl::Completion::Context'); … … 108 132 1, -1, 7, 12); 109 133 134 ## Test Context::shift 135 test_shift('lorem ipsum dolor ', 'sit amet', 0, 136 [qw(lorem ipsum dolor sit amet)], 137 3, 0, 18, 21); 138 139 test_shift('lorem ipsum dolor ', 'sit amet', 1, 140 [qw(ipsum dolor sit amet)], 141 2, 0, 12, 15); 142 143 test_shift('lorem ipsum dolor ', 'sit amet', 2, 144 [qw(dolor sit amet)], 145 1, 0, 6, 9); 146 147 test_shift('lorem ipsum dolor ', 'sit amet', 3, 148 [qw(sit amet)], 149 0, 0, 0, 3); 150 151 eval { 152 my $before_point = 'lorem ipsum dolor'; 153 my $after_point = 'sit amet'; 154 my $shift = 4; 155 156 my $ctx = BarnOwl::Completion::Context->new($before_point, 157 $after_point); 158 $ctx = $ctx->shift_words($shift); 159 }; 160 like($@, qr/^Context::shift: Unable to shift /, "Correctly die when shifting away the point"); 110 161 111 162 ## Test common_prefix … … 163 214 164 215 test_complete('zwrite -c nelhage ', '', 165 [qw(-n -C -m - c -i -r -O nelhage asedeno geofft)]);216 [qw(-n -C -m -i -r -O nelhage asedeno geofft)]); 166 217 167 218 test_complete('zwrite -c nelhage ', '-', 168 [qw(-n -C -m - c -i -r -O nelhage asedeno geofft)]);219 [qw(-n -C -m -i -r -O nelhage asedeno geofft)]); 169 220 170 221 test_complete('zwrite -c nelhage -- ', '', … … 178 229 "-d" => sub {qw(some words for completing)}, 179 230 }, 180 sub {$_[1]}); 231 sub {$_[1]}, 232 repeat_flags => 1); 181 233 } 182 234 … … 203 255 [qw(2)], \&complete_word); 204 256 257 258 # Test the filter expression completer 259 test_complete('', '', 260 [qw[( body class direction false filter hostname instance login not opcode perl realm recipient sender true type]], 261 \&complete_filter_expr); 262 263 test_complete('not ', '', 264 [qw[( body class direction false filter hostname instance login not opcode perl realm recipient sender true type]], 265 \&complete_filter_expr); 266 267 test_complete('true ', '', 268 [qw[and or]], 269 \&complete_filter_expr); 270 271 test_complete('( true ', '', 272 [qw[and or )]], 273 \&complete_filter_expr); 274 275 test_complete('( body static and body analysis and not false and class davidben and ( instance python or instance hotd ', '', 276 [qw[and or )]], 277 \&complete_filter_expr); 278 279 test_complete('type ', '', 280 [qw[admin aim zephyr]], 281 \&complete_filter_expr); 282 283 test_complete('direction ', '', 284 [qw[in out none]], 285 \&complete_filter_expr); 286 287 test_complete('login ', '', 288 [qw[login logout none]], 289 \&complete_filter_expr); 290 205 291 1; 206 292 -
t/mock.pl
r776c4bb r42ad917 7 7 use Carp; 8 8 9 sub bootstrap {}10 9 sub get_data_dir {"."} 11 10 sub get_config_dir {"."}
Note: See TracChangeset
for help on using the changeset viewer.
