File: 02_main.t

package info (click to toggle)
libobject-signature-perl 1.08-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 268 kB
  • sloc: perl: 266; makefile: 2
file content (77 lines) | stat: -rwxr-xr-x 1,543 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl

# Load testing for Object::Signature

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More tests => 17;

# Test a trivial example
my $Foo1 = Foo->new;
isa_ok( $Foo1, 'Foo' );
isa_ok( $Foo1, 'Object::Signature' );
ok( $Foo1->signature, '->signature returns true' );
is( length($Foo1->signature), 32, '->signature returns 32 chars' );
is( $Foo1->signature, $Foo1->signature, 'Multiple ->signature calls return the same' );

my $Foo2 = Foo->new;
isa_ok( $Foo2, 'Foo' );
is( length($Foo2->signature), 32, '->signature returns 32 chars' );
is( $Foo1->signature, $Foo2->signature, 'Multiple identical objects return the same ->signature' );

my $Bar1 = Bar->new;
isa_ok( $Bar1, 'Bar' );
isa_ok( $Bar1, 'Object::Signature' );
ok( $Bar1->signature, '->signature returns true' );
is( length($Bar1->signature), 32, '->signature returns 32 chars' );
isnt(
	$Foo1->signature,
	$Bar1->signature,
	'Identical objects of different classes return different signatures',
);

my $Bar2 = Bar->new;
isa_ok( $Bar2, 'Bar' );
ok( $Bar2->signature, '->signature returns true' );
is( length($Bar2->signature), 32, '->signature returns 32 chars' );
isnt(
	$Bar1->signature,
	$Bar2->signature,
	'Different objects of the same class return different signatures',
);





BEGIN {
	package Foo;

	use Object::Signature ();

	@Foo::ISA = 'Object::Signature';

	sub new {
		bless { a => 1 }, 'Foo'
	};

	1;

	package Bar;

	use Object::Signature ();

	@Bar::ISA = 'Object::Signature';

	my $bar = 0;

	sub new {
		bless { a => ++$bar }, 'Bar'
	}

	1;
}