From: Vincent Pit Date: Sun, 25 Jul 2010 17:58:09 +0000 (+0200) Subject: Test method calls X-Git-Tag: v0.06~1 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Fsubs-auto.git;a=commitdiff_plain;h=c74fc9e2cabbdca5b8c760a3bbd17624a8f1d19e Test method calls --- diff --git a/MANIFEST b/MANIFEST index 6444beb..f014427 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,6 +11,7 @@ t/05-args.t t/10-base.t t/11-pkg.t t/12-proto.t +t/13-meth.t t/91-pod.t t/92-pod-coverage.t t/95-portability-files.t diff --git a/t/13-meth.t b/t/13-meth.t new file mode 100644 index 0000000..db8ee14 --- /dev/null +++ b/t/13-meth.t @@ -0,0 +1,33 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 2 * 4; + +my %res; + +eval q[ + package subs::auto::Test; + use subs::auto; + $res{"${_}2"} = __PACKAGE__->can($_) ? 1 : 0 for qw/foo bar baz qux/; + return; + BEGIN { $res{foo} = __PACKAGE__->can('foo') ? 1 : 0; } + sub bar; + BEGIN { $res{bar} = __PACKAGE__->can('bar') ? 1 : 0; } + baz 1; + BEGIN { $res{baz} = __PACKAGE__->can('baz') ? 1 : 0; } + BEGIN { $res{qux} = __PACKAGE__->can('qux') ? 1 : 0; } + qux 3, 4; +]; +die $@ if $@; + +is $res{foo}, 0, 'foo at compile time'; +is $res{bar}, 1, 'bar at compile time'; +is $res{baz}, 0, 'baz at compile time'; +is $res{qux}, 0, 'qux at compile time'; + +is $res{foo2}, 0, 'foo at run time'; +is $res{bar2}, 1, 'bar at run time'; +is $res{baz2}, 0, 'baz at run time'; +is $res{qux2}, 0, 'qux at run time';