File: immutable.t

package info (click to toggle)
libobject-id-perl 0.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 188 kB
  • sloc: perl: 289; makefile: 2
file content (27 lines) | stat: -r--r--r-- 427 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
#!/usr/bin/perl

# Demonstrate that the ID does not change with the object's contents.

use strict;
use warnings;

use Test::More;

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

    sub new {
        my $class = shift;
        bless {}, $class;
    }
}

{
    my $obj = new_ok "My::Class";
    my $id = $obj->object_id;
    $obj->{foo} = 42;
    is $obj->object_id, $id, "ID is independent of object content";
}

done_testing;