- my ($pkg) = @_;
- qr/^warn:Indirect\s+call\s+of\s+method\s+
- "(?:new|meh|feh|$pkg$pkg)"
- \s+on\s+object\s+
- "(?:$pkg|newnew|feh|\$(?:[xyz_\$]|(?:sploosh::)?sploosh|(?:main::)?bloop))"
- \s+at\s+\(eval\s+\d+\)\s+line\s+\d+
- /x
+ my ($expected) = @_;
+
+ die unless $expected;
+
+ map {
+ my ($meth, $obj, $file, $line) = @$_;
+ $_ = quotemeta for $meth, $obj;
+ $file = '\(eval \d+\)' unless defined $file;
+ $line = '\d+' unless defined $line;
+ qr/^Indirect call of method "$meth" on object "$obj" at $file line $line/
+ } eval $expected;
+}
+
+my @warns;
+
+sub try {
+ my ($code) = @_;
+
+ @warns = ();
+ {
+ local $SIG{__WARN__} = sub { push @warns, join(' ', @_) };
+ eval $code;
+ }