13 # /p Pattern PRE MATCH POST
14 [ 'p', "456", "123-", "456", "-789"],
15 [ '', "(456)", "123-", "456", "-789"],
16 [ '', "456", undef, undef, undef ],
19 plan tests => 4 * @tests + 2;
22 $SIG{__WARN__} = sub { $W.=join("",@_); };
23 sub _u($$) { "$_[0] is ".(defined $_[1] ? "'$_[1]'" : "undef") }
26 foreach my $test (@tests) {
27 my ($p, $pat,$l,$m,$r) = @$test;
28 my $test_name = "/$pat/$p";
29 my $ok = ok($p ? /$pat/p : /$pat/, $test_name);
31 skip "/$pat/$p failed to match", 3
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 );
38 is($W,"","No warnings should be produced");
39 ok(!defined ${^MATCH}, "No /p in scope so ^MATCH is undef");