File: bool.t

package info (click to toggle)
libdata-perl-perl 0.002011-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 364; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 555 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use Test::More;
use Data::Perl;
use strict;

use Scalar::Util qw/refaddr/;

# constructor
is ref(bool(1)), 'Data::Perl::Bool', 'constructor shortcut works';

my $b = bool(5);
is $$b, 1, 'nondefault set reduces to 1';

$b = bool();
is $$b, 0, 'default set reduces to 0';

# set
$b->set();
is $$b, 1, 'set sets to 1';
$b->set();

# unset
$b->unset;
is $$b, 0, 'unset works.';

# toggle
$b->toggle;
is $$b, 1, 'toggle works';
$b->toggle;
is $$b, 0, 'toggle works';

# not
is $b->not, 1, 'not works';
$b->toggle;
is $b->not, '', 'not works';

done_testing();