Add a test that "eval" does not create additional reference to ouside variables.
[p5sagit/p5-mst-13.2.git] / t / op / mydef.t
index d2ff35b..e034c78 100644 (file)
@@ -1,14 +1,15 @@
-#!./perl -w
+#!./perl
 
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
+    require './test.pl';
 }
 
-print "1..70\n";
+print "1..72\n";
 
 my $test = 0;
-sub ok ($$) {
+sub ok ($@) {
     my ($ok, $name) = @_;
     ++$test;
     print $ok ? "ok $test - $name\n" : "not ok $test - $name\n";
@@ -175,8 +176,7 @@ $_ = "global";
     ::ok( $1 eq 'notmain', '...m// defaults to our $_ in main::' );
 }
 
-my $file = 'dolbar1.tmp';
-END { unlink $file; }
+my $file = tempfile();
 {
     open my $_, '>', $file or die "Can't open $file: $!";
     print $_ "hello\n";
@@ -198,3 +198,21 @@ END { unlink $file; }
     ::ok( $_ ne 'fqdb', 'unqualified $_ is in main' );
     ::ok( q/$_/ ne 'fqdb', 'unqualified, evaled $_ is in main' );
 }
+
+{
+    $clank_est::qunckkk = 3;
+    our $qunckkk;
+    $qunckkk = 4;
+    package clank_est;
+    our $qunckkk;
+    ::ok($qunckkk == 3, 'regular variables are not forced to main');
+}
+
+{
+    $whack::_ = 3;
+    our $_;
+    $_ = 4;
+    package whack;
+    our $_;
+    ::ok($_ == 4, '$_ is "special", and always forced to main');
+}