From: Vincent Pit Date: Wed, 22 Oct 2008 14:38:09 +0000 (+0200) Subject: Test state variables X-Git-Tag: v0.08~1 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=commitdiff_plain;h=faed8ab9b402954feb3efbffbb1ce53aafd53fc1 Test state variables --- diff --git a/t/10-good.t b/t/10-good.t index 708397f..6559b54 100644 --- a/t/10-good.t +++ b/t/10-good.t @@ -9,10 +9,13 @@ package main; use strict; use warnings; -use Test::More tests => 49 * 4; +use Test::More tests => 53 * 4; + +use feature 'state'; my ($obj, $pkg, $cb, $x, @a); our $y; +state $z; sub meh; { @@ -143,6 +146,10 @@ meh $y; #### meh $y, 1, 2; #### +meh $z; +#### +meh $z, 1, 2; +#### print; #### print $_; @@ -155,6 +162,10 @@ print $y; #### print $y "dongs\n"; #### +print $z; +#### +print $z "hlagh\n"; +#### print STDOUT "bananananananana\n"; #### $x->foo($pkg->$cb) diff --git a/t/20-bad.t b/t/20-bad.t index a545108..136b381 100644 --- a/t/20-bad.t +++ b/t/20-bad.t @@ -9,14 +9,17 @@ package main; use strict; use warnings; -use Test::More tests => 47 * 6 + 2; +use Test::More tests => 50 * 6 + 2; + +use feature 'state'; my ($obj, $x); our ($y, $bloop); +state $z; sub expect { my ($pkg) = @_; - return qr/^warn:Indirect call of method "(?:new|meh|$pkg$pkg)" on object "(?:$pkg|newnew|\$(?:[xy_\$]|(?:sploosh::)?sploosh|(?:main::)?bloop))"/ + return qr/^warn:Indirect call of method "(?:new|meh|$pkg$pkg)" on object "(?:$pkg|newnew|\$(?:[xyz_\$]|(?:sploosh::)?sploosh|(?:main::)?bloop))"/ } { @@ -149,6 +152,12 @@ meh $y 1, 2; #### meh $y, 1, 2; #### +meh $z; +#### +meh $z 1, 2; +#### +meh $z, 1, 2; +#### package sploosh; our $sploosh; meh $sploosh::sploosh;