|
Lines 23-39
use_ok('Koha::Result::Boolean');
Link Here
|
| 23 |
|
23 |
|
| 24 |
subtest 'new() tests' => sub { |
24 |
subtest 'new() tests' => sub { |
| 25 |
|
25 |
|
| 26 |
plan tests => 4; |
26 |
plan tests => 2; |
| 27 |
|
27 |
|
| 28 |
ok( Koha::Result::Boolean->new, |
28 |
subtest 'bool context' => sub { |
| 29 |
'Defaults to true if initialized without the parameter' ); |
29 |
|
| 30 |
ok( Koha::Result::Boolean->new('Martin'), |
30 |
plan tests => 4; |
| 31 |
'Evals to true in boolean context if set an expression that evals to true' ); |
31 |
|
| 32 |
ok( !Koha::Result::Boolean->new(0), |
32 |
ok( Koha::Result::Boolean->new, |
| 33 |
'Evals to false in boolean context if set a false expression' ); |
33 |
'Defaults to true if initialized without the parameter' ); |
| 34 |
ok( !Koha::Result::Boolean->new(""), |
34 |
ok( Koha::Result::Boolean->new('Martin'), |
| 35 |
'Evals to false in boolean context if set a false expression' ); |
35 |
'Evals to true in boolean context if set an expression that evals to true' ); |
| 36 |
|
36 |
ok( !Koha::Result::Boolean->new(0), |
|
|
37 |
'Evals to false in boolean context if set a false expression' ); |
| 38 |
ok( !Koha::Result::Boolean->new(""), |
| 39 |
'Evals to false in boolean context if set a false expression' ); |
| 40 |
}; |
| 41 |
|
| 42 |
subtest '== context' => sub { |
| 43 |
|
| 44 |
plan tests => 4; |
| 45 |
|
| 46 |
cmp_ok( Koha::Result::Boolean->new, '==', 1, |
| 47 |
'Defaults 1 if initialized without the parameter' ); |
| 48 |
cmp_ok( Koha::Result::Boolean->new('Martin'), '==', 1, |
| 49 |
'Evals 1 if set an expression that evals to true' ); |
| 50 |
cmp_ok( Koha::Result::Boolean->new(0), '==', 0, |
| 51 |
'Evals 0 if set a false expression' ); |
| 52 |
cmp_ok( Koha::Result::Boolean->new(""), '==', 0, |
| 53 |
'Evals 0 if set a false expression' ); |
| 54 |
}; |
| 37 |
}; |
55 |
}; |
| 38 |
|
56 |
|
| 39 |
subtest 'set_value() tests' => sub { |
57 |
subtest 'set_value() tests' => sub { |
| 40 |
- |
|
|