File: refcount.t

package info (click to toggle)
libset-object-perl 1.02-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 104 kB
  • ctags: 26
  • sloc: perl: 148; makefile: 44
file content (43 lines) | stat: -rw-r--r-- 939 bytes parent folder | download
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
use Set::Object;

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

print "1..8\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 = 100;
my $big = Set::Object->new( map { Person->new } 1..$n );
print 'not ' if $Person::n != $n;
print "ok 7\n";

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