File: 04debug.t

package info (click to toggle)
libdata-phrasebook-perl 0.35-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: perl: 1,242; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,334 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl -w
use strict;
use vars qw( $class );

use Test::More tests => 13;

# ------------------------------------------------------------------------

BEGIN {
    $class = 'Data::Phrasebook';
    use_ok $class;
}

my $file = 't/01phrases.txt';
my %trail = (
	1 => 0,
	2 => 0,
	3 => 11,
	4 => 29,
);

# ------------------------------------------------------------------------

{
    my $obj = $class->new;
    isa_ok( $obj => "${class}::Plain", 'Bare new' );
    is( $obj->debug => 0 , 'Set/get debug works');
}

{
    my $obj = $class->new( file => $file, debug => 4 );
    isa_ok( $obj => "${class}::Plain", 'New with file' );
    is( $obj->debug => 4 , 'Set/get debug works');

    {
        my $str = $obj->fetch( 'foo', {
                my => "Iain's",
                place => 'locale',
            });
    }

    {
        $obj->delimiters( qr{ :(\w+) }x );

        my $str = $obj->fetch( 'bar', {
                my => "Bob's",
                place => 'whatever',
            });
    }

	for(1..4) {
		my @log = $obj->retrieve($_);
		is(scalar(@log),$trail{$_});
	}

	$obj->clear();
	{
		my @log = $obj->retrieve(4);
		is(scalar(@log),$trail{1});
		@log = $obj->retrieve();
		is(scalar(@log),$trail{1});

		my $items = $obj->store();
		is($items,undef);
		$items = $obj->store(5,'hello');
		is($items,undef);
	}
}