File: object.t

package info (click to toggle)
libwant-perl 0.18-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 132 kB
  • ctags: 15
  • sloc: perl: 163; makefile: 55
file content (42 lines) | stat: -rw-r--r-- 921 bytes parent folder | download | duplicates (8)
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
BEGIN { $| = 1; print "1..7\n"; }

# Test that we can load the module
END {print "not ok 1\n" unless $loaded;}
use Want;
$loaded = 1;
print "ok 1\n";

# Test the OBJECT reference type

sub t {
    my $t = shift();
    my $opname = Want::parent_op_name(0);
    print ($opname eq shift() ? "ok $t\n" : "not ok $t\t# $opname\n");
    wantarray ? @_ : shift;
}

sub nop{}
my $obj = bless({}, "main");

t(2, "method_call", $obj)->nop("blast");
t(3, "entersub", \&nop)->("blamm!");

sub wrt {
    my $t = shift();
    my $wantref = Want::wantref();
    my $expected = shift();
    print ($wantref eq $expected ? "ok $t\n" : "not ok $t\t# $wantref\n");
    wantarray ? @_ : shift;
}

wrt(4, "OBJECT", $obj)->nop();
wrt(5, "CODE",  \&nop)->(nop());

sub wantt {
    my $t = shift();
    my $r = shift();
    print (Want::want(@_) ? "ok $t\n" : "not ok $t\n");
    $r
}

wantt(6, $obj, 'OBJECT')->nop(wantt(7, \&nop, 'CODE')->());