File: refcount.t

package info (click to toggle)
libset-object-perl 1.42-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 620 kB
  • sloc: perl: 1,069; makefile: 14
file content (49 lines) | stat: -rw-r--r-- 1,044 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
use Set::Object;

require './t/object/Person.pm';
package Person;

print "1..9\n";

$simpsons = Set::Object->new(
   new Person( firstname => 'Bart', name => 'Simpson' ),
   new Person( firstname => 'Lisa', name => 'Simpson' ),
   new Person( firstname => 'Maggie', name => 'Simpson' ) );

print 'not' unless $Person::n == 3;
print "ok 1\n";

$simpsons->insert();
print 'not ' unless $Person::n == 3;
print "ok 2\n";

$simpsons->insert($homer = new Person( firstname => 'Homer', name => 'Simpson' ));
print 'not ' unless $Person::n == 4;
print "ok 3\n";

$simpsons->remove($homer);
print 'not ' unless $Person::n == 4;
print "ok 4\n";

undef $homer;
print 'not ' unless $Person::n == 3;
print "ok 5\n";

$simpsons = undef;
print 'not ' if $Person::n;
print "ok 6\n";

my $n = 31;
my $big = Set::Object->new( map { Person->new } 1..$n );
print 'not ' if $Person::n != $n;
print "ok 7\n";

{
	my $same = $big - Set::Object->new();
	print 'not ' if $same->size != $n;
	print "ok 8\n";
}

$big->clear();
print 'not ' if $Person::n;
print "ok 9\n";