File: 230_tags.t

package info (click to toggle)
libtest-regexp-perl 2017040101-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 220 kB
  • sloc: perl: 1,331; makefile: 2
file content (53 lines) | stat: -rwxr-xr-x 981 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

use strict;
use warnings;
no  warnings 'syntax';

use 5.010;

use Test::More 0.88;
use Test::Regexp import => [];

#
# Check to see whether the objects remember 'tags'
#

my $obj1 = Test::Regexp:: -> new -> init (
    pattern => 'foo',
    tags    => {
        -foo => 1,
        -bar => 2,
    }
);


my $obj2 = Test::Regexp:: -> new -> init (
    pattern => 'foo',
    tags    => {
        -bar => 1,
        -baz => 3,
        -baz => 4,
        -qux => 5,
    }
);
      

is $obj1 -> tag ('-foo'),  1, "Tag";
is $obj1 -> tag ('-bar'),  2, "Tag";
is $obj2 -> tag ('-bar'),  1, "Tag";
is $obj2 -> tag ('-baz'),  4, "Tag";
is $obj2 -> tag ('-qux'),  5, "Tag";


$obj2 -> set_tag (-quux => 6);
$obj2 -> set_tag (-bar  => 7);

is $obj1 -> tag ('-foo'),  1, "Tag";
is $obj1 -> tag ('-bar'),  2, "Tag";
is $obj2 -> tag ('-bar'),  7, "Tag";
is $obj2 -> tag ('-baz'),  4, "Tag";
is $obj2 -> tag ('-qux'),  5, "Tag";
is $obj2 -> tag ('-quux'), 6, "Tag";

done_testing;