Warning bit fixes to t/op/caller.t
[p5sagit/p5-mst-13.2.git] / t / op / regexp_pmod.t
CommitLineData
cde0cee5 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
9use strict;
10use warnings;
11
12our @tests = (
87e95b7f 13 # /p Pattern PRE MATCH POST
14 [ 'p', "456", "123-", "456", "-789"],
cde0cee5 15 [ '', "(456)", "123-", "456", "-789"],
16 [ '', "456", undef, undef, undef ],
17);
18
19plan tests => 4 * @tests + 2;
20my $W = "";
21
22$SIG{__WARN__} = sub { $W.=join("",@_); };
23sub _u($$) { "$_[0] is ".(defined $_[1] ? "'$_[1]'" : "undef") }
24
25$_ = '123-456-789';
26foreach my $test (@tests) {
87e95b7f 27 my ($p, $pat,$l,$m,$r) = @$test;
28 my $test_name = "/$pat/$p";
29 my $ok = ok($p ? /$pat/p : /$pat/, $test_name);
cde0cee5 30 SKIP: {
87e95b7f 31 skip "/$pat/$p failed to match", 3
cde0cee5 32 unless $ok;
33 is(${^PREMATCH}, $l,_u "$test_name: ^PREMATCH",$l);
34 is(${^MATCH}, $m,_u "$test_name: ^MATCH",$m );
35 is(${^POSTMATCH}, $r,_u "$test_name: ^POSTMATCH",$r );
36 }
37}
38is($W,"","No warnings should be produced");
87e95b7f 39ok(!defined ${^MATCH}, "No /p in scope so ^MATCH is undef");