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
|
#!/usr/bin/perl -w
use Test;
BEGIN {
if ($] < 5.008001) {
print "# +autodispatch broken in 5.8.0\n";
plan tests => 0;
exit 0;
}
}
package foo;
sub new {
my $class = shift;
my $self = {count => 0,};
bless $self, $class;
}
sub bar {
my $self = shift;
++$self->{count};
}
sub proxy {
my $self = shift;
my $meth = shift;
if ($self->can($meth)) {
return $self->$meth;
} else {
return;
}
}
# This code works if it's a regular class
package main;
use Test;
plan tests => 3;
my $f = new foo();
use SOAP::Lite +autodispatch =>
uri => 'http://example.org/foo',
proxy => 'http://example.org.cgi';
ok $f->bar() == 1;
if ($f->can("bar")) {
ok $f->bar == 2;
}
if ($f->can("proxy")) {
ok $f->proxy("bar") == 3;
}
|