File: 031synchronize.t

package info (click to toggle)
libtm-perl 1.56-3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,852 kB
  • sloc: perl: 35,234; sh: 565; makefile: 47
file content (49 lines) | stat: -rw-r--r-- 1,188 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
use strict;
use warnings;

# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More qw(no_plan);

use Data::Dumper;
$Data::Dumper::Indent = 1;

#== TESTS ===========================================================================

use TM;

require_ok( 'TM::Synchronizable::Null' );

can_ok 'TM::Synchronizable::Null', 'apply';

Class::Trait->apply ('TM' => qw(TM::Synchronizable::Null));

{ # structural tests
    my $tm = new TM (baseuri => 'tm:');
    ok ($tm->isa('TM'),                 'correct class');

    ok ($tm->does ('TM::Synchronizable::Null'), 'trait: Null');
    ok ($tm->can ('sync_in'),             'trait: can in');
    ok ($tm->can ('sync_out'),            'trait: can out');
}

{
    my $tm = new TM (url => 'io:stdin');
    $tm->sync_in;
    $tm->sync_out;
    is ($tm->{_ins},  1,     'once in');
    is ($tm->{_outs}, undef, 'never out');

    $tm->url ('io:stdout');
    $tm->sync_in;
    $tm->sync_out;
    is ($tm->{_ins},  2,     'once in');
    is ($tm->{_outs}, undef, 'not out');

    $tm->consolidate; # do something, whatever
    $tm->sync_out;
    is ($tm->{_ins},  2,     'once in');
    is ($tm->{_outs}, 1,     'finally out');

}

__END__