File: Catmandu-Exporter.t

package info (click to toggle)
libcatmandu-perl 1.0304-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,756 kB
  • ctags: 695
  • sloc: perl: 13,756; makefile: 34
file content (47 lines) | stat: -rw-r--r-- 666 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use Test::Exception;
use Role::Tiny;

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Exporter';
    use_ok $pkg;
}
require_ok $pkg;

{

    package T::ExporterWithoutAdd;
    use Moo;

    package T::Exporter;
    use Moo;
    with $pkg;

    sub add { }

}

throws_ok {Role::Tiny->apply_role_to_package('T::ExporterWithoutAdd', $pkg)}
qr/missing add/;

my $e = T::Exporter->new;
ok $e->does('Catmandu::Addable');
ok $e->does('Catmandu::Counter');
can_ok $e, 'encoding';
can_ok $e, 'commit';

is $e->encoding, ':utf8';

$e->add(1);
is $e->count, 1;
$e->add_many([2, 3, 4]);
is $e->count, 4;

done_testing 10;