Add a test that "eval" does not create additional reference to ouside variables.
[p5sagit/p5-mst-13.2.git] / t / op / qr.t
index ff9449e..acabd28 100644 (file)
--- a/t/op/qr.t
+++ b/t/op/qr.t
@@ -1,13 +1,41 @@
 #!./perl -w
 
-BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    require './test.pl';
+use strict;
+
+require './test.pl';
+
+plan(tests => 12);
+
+sub r {
+    return qr/Good/;
 }
 
-plan tests => 1;
+my $a = r();
+isa_ok($a, 'Regexp');
+my $b = r();
+isa_ok($b, 'Regexp');
+
+my $b1 = $b;
+
+isnt($a + 0, $b + 0, 'Not the same object');
+
+bless $b, 'Pie';
+
+isa_ok($b, 'Pie');
+isa_ok($a, 'Regexp');
+isa_ok($b1, 'Pie');
+
+my $c = r();
+like("$c", qr/Good/);
+my $d = r();
+like("$d", qr/Good/);
+
+my $d1 = $d;
+
+isnt($c + 0, $d + 0, 'Not the same object');
 
-my $rx = qr//;
+$$d = 'Bad';
 
-is(ref $rx, "Regexp", "qr// blessed into `Regexp' by default");
+like("$c", qr/Good/);
+like("$d", qr/Bad/);
+like("$d1", qr/Bad/);