File: role.t

package info (click to toggle)
libobject-id-perl 0.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 176 kB
  • ctags: 9
  • sloc: perl: 291; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 772 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
48
49
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

{
    package My::Class;
    use Object::ID;

    sub new {
        my $class = shift;
        my $ref   = shift;

        bless $ref, $class;
    }
}


# Hashref
{
    my $obj = new_ok "My::Class", [{}];
    ok $obj->object_id;
    is $obj->object_id, $obj->object_id;

    my $copy = $obj;
    is $obj->object_id, $copy->object_id;

    my $obj2 = new_ok "My::Class", [{}];
    isnt $obj->object_id, $obj2->object_id;
}


# Coderef
{
    my $obj = new_ok "My::Class", [sub { 42 }];
    ok $obj->object_id;

    my $copy = $obj;
    is $obj->object_id, $copy->object_id;

    my $obj2 = new_ok "My::Class", [sub { 42 }];
    ok $obj2->object_id;
    isnt $obj->object_id, $obj2->object_id;
}


done_testing();