3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 15; |
use Test::More tests => 22; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
#use Data::Dumper; |
#use Data::Dumper; |
9 |
|
|
12 |
ok(my $cond = new Search::Estraier::Condition, 'new'); |
ok(my $cond = new Search::Estraier::Condition, 'new'); |
13 |
isa_ok($cond, 'Search::Estraier::Condition'); |
isa_ok($cond, 'Search::Estraier::Condition'); |
14 |
|
|
15 |
|
cmp_ok($cond->max, '==', -1, 'max'); |
16 |
|
cmp_ok($cond->options, '==', 0, 'options'); |
17 |
|
|
18 |
ok($cond->set_phrase('search'), 'set_phrase'); |
ok($cond->set_phrase('search'), 'set_phrase'); |
19 |
ok($cond->add_attr('@foo BAR baz'), 'set_phrase'); |
ok($cond->add_attr('@foo BAR baz'), 'set_attr'); |
20 |
ok($cond->set_order('@foo ASC'), 'set_order'); |
ok($cond->set_order('@foo ASC'), 'set_order'); |
21 |
ok($cond->set_max(42), 'set_max, number'); |
ok($cond->set_max(42), 'set_max, number'); |
22 |
throws_ok { $cond->set_max('foo') } qr/number/, 'set_max, NaN'; |
throws_ok { $cond->set_max('foo') } qr/number/, 'set_max, NaN'; |
25 |
ok($cond->set_options( $opt ), 'set_option '.$opt); |
ok($cond->set_options( $opt ), 'set_option '.$opt); |
26 |
} |
} |
27 |
|
|
28 |
cmp_ok($cond->phrase, 'eq', 'search', 'phrase'); |
my $v; |
29 |
|
cmp_ok($v = $cond->phrase, 'eq', 'search', "phrase: $v"); |
30 |
|
cmp_ok($v = $cond->max, '==', 42, "max: $v"); |
31 |
|
cmp_ok($v = $cond->options, '!=', 0, "options: $v"); |
32 |
|
|
33 |
|
#diag "attrs: ",join(",",$cond->attrs); |
34 |
|
cmp_ok($cond->attrs, '==', 1, 'one attrs'); |
35 |
|
ok($cond->add_attr('@foo2 BAR2 baz2'), 'set_attr'); |
36 |
|
#diag "attrs: ",join(",",$cond->attrs); |
37 |
|
cmp_ok($cond->attrs, '==', 2, 'two attrs'); |