Re: [perl #27028] /$/ not honouring /m in some cases

2005-07-18 Thread Rafael Garcia-Suarez
On 7/14/05, Rick Delaney [EMAIL PROTECTED] wrote:
 Here's one way.  Line 614 of t/op/re_tests fits the bill.  I'm a little
 disappointed that this patch didn't shake out any more bugs.  I guess
 we're getting close to a bug-free regex engine.  ;-)

Thanks, almost a thousand tests added as change #25166.


[perl #27028] /$/ not honouring /m in some cases

2005-07-14 Thread Michael G Schwern via RT
 [EMAIL PROTECTED] - Mon Feb 23 15:11:06 2004]:
 
 Test case #0:
   perl -e '$eol = qr/$/m; foo\nbar\n =~ /$eol/; print $-[0], \n'
 
 Test case #1:
   perl -e '$eol = qr/$/m; foo\nbar\n =~ /$eol(?:)/; print $-[0],
\n'
 
 I'm getting the answer 7 from case #0 and 3 from case #1.  The correct
 answer is 3.  (The /$/m pattern should match at the embedded newline
at
 position 3.)

[EMAIL PROTECTED] reports 3 for both cases.


 Test case #2:
   perl -e '$eol = qr/$/; foo\nbar\n =~ /$eol/m; print $-[0], \n'
 
 #2 is the converse of #1; it outputs 3 where it should output 7.

bleadperl reports 7.

I believe this bug is fixed but I'd like to see a test added before
closing it.  The regex tests scare me.


Re: [perl #27028] /$/ not honouring /m in some cases

2005-07-14 Thread Rick Delaney
On Thu, Jul 14, 2005 at 03:52:45AM -0700, Michael G Schwern via RT wrote:
 I believe this bug is fixed but I'd like to see a test added before
 closing it.  The regex tests scare me.

Here's one way.  Line 614 of t/op/re_tests fits the bill.  I'm a little
disappointed that this patch didn't shake out any more bugs.  I guess
we're getting close to a bug-free regex engine.  ;-)

If you don't like having an extra 900+ tests then I suppose adding a
line like:

'$(?:)'mb\na\n  y   $-[0]   1

or

(?m:$)(?:)b\na\n  y   $-[0]   1

to t/op/re_tests would suffice.  But that doesn't test the embedding of
a qr/pattern/m in another pattern.

-- 
Rick Delaney
[EMAIL PROTECTED]


diff -ruN perl-current/t/op/regexp.t perl-current-dev/t/op/regexp.t
--- perl-current/t/op/regexp.t  2004-11-04 05:56:08.0 -0500
+++ perl-current-dev/t/op/regexp.t  2005-07-14 09:11:33.293055207 -0400
@@ -74,7 +74,21 @@
 $result =~ s/B//i unless $skip;
 for $study ('', 'study \$subject') {
$c = $iters;
-   eval $study; \$match = (\$subject =~ $OP$pat) while \$c--; \$got = 
\$repl\;;
+if ($qr_embed) {
+   eval qq
+my \$RE = qr$pat;
+$study;
+\$match = (\$subject =~ /(?:)\$RE(?:)/) while \$c--;
+\$got = \$repl\;
+;
+} 
+else {
+   eval qq
+$study;
+\$match = (\$subject =~ $OP$pat) while \$c--;
+\$got = \$repl\;
+;
+}
chomp( $err = $@ );
if ($result eq 'c') {
if ($err !~ m!^\Q$expect!) { print not ok $. (compile) $input = 
`$err'\n; next TEST }
diff -ruN perl-current/t/op/regexp_qr_embed.t 
perl-current-dev/t/op/regexp_qr_embed.t
--- perl-current/t/op/regexp_qr_embed.t 1969-12-31 19:00:00.0 -0500
+++ perl-current-dev/t/op/regexp_qr_embed.t 2005-07-14 09:56:24.497124417 
-0400
@@ -0,0 +1,11 @@
+#!./perl
+
+$qr = 1;
+$qr_embed = 1;
+for $file ('./op/regexp.t', './t/op/regexp.t', ':op:regexp.t') {
+if (-r $file) {
+   do $file;
+   exit;
+}
+}
+die Cannot find ./op/regexp.t or ./t/op/regexp.t\n;


Re: [perl #27028] /$/ not honouring /m in some cases

2005-07-14 Thread hv
Rick Delaney [EMAIL PROTECTED] wrote:
:I guess we're getting close to a bug-free regex engine.  ;-)

g

:But that doesn't test the embedding of a qr/pattern/m in another pattern.

You can add random tests to op/pat.t for anything that can't be squeezed
into re_tests.

Hugo


Re: [perl #27028] /$/ not honouring /m in some cases

2005-07-14 Thread Michael G Schwern
On Thu, Jul 14, 2005 at 10:10:59AM -0400, Rick Delaney wrote:
 to t/op/re_tests would suffice.  But that doesn't test the embedding of
 a qr/pattern/m in another pattern.

Sounds like a fine hammer to hit the regex engine with.


-- 
Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
Reality is that which, when you stop believing in it, doesn't go away.
-- Phillip K. Dick