Make C<undef ~~ 0> and C<undef ~~ ""> not match (like in 5.10.0)
[p5sagit/p5-mst-13.2.git] / t / op / mydef.t
index 0770e78..444bf4a 100644 (file)
@@ -1,14 +1,15 @@
-#!./perl -w
+#!./perl
 
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
+    require './test.pl';
 }
 
-print "1..64\n";
+print "1..70\n";
 
 my $test = 0;
-sub ok ($$) {
+sub ok ($@) {
     my ($ok, $name) = @_;
     ++$test;
     print $ok ? "ok $test - $name\n" : "not ok $test - $name\n";
@@ -118,6 +119,12 @@ $_ = "global";
     ok( $x eq '1globallocal-2globallocal', 'map without {}' );
 }
 {
+    for my $_ (1) {
+       my $x = map $_, qw(a b);
+       ok( $x == 2, 'map in scalar context' );
+    }
+}
+{
     my $buf = '';
     sub tgrep1 { /(.)/; $buf .= $1 }
     my $_ = 'y';
@@ -142,6 +149,12 @@ $_ = "global";
     ok( $_ eq 'local', '...but without extraneous side-effects' );
 }
 {
+    for my $_ (1) {
+       my $x = grep $_, qw(a b);
+       ok( $x == 2, 'grep in scalar context' );
+    }
+}
+{
     my $s = "toto";
     my $_ = "titi";
     $s =~ /to(?{ ok( $_ eq 'toto', 'my $_ in code-match # TODO' ) })to/
@@ -152,7 +165,7 @@ $_ = "global";
 {
     my $_ = "abc";
     my $x = reverse;
-    ok( $x eq "cba", 'reverse without arguments picks up $_ # TODO' );
+    ok( $x eq "cba", 'reverse without arguments picks up $_' );
 }
 
 {
@@ -163,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";
@@ -177,3 +189,12 @@ END { unlink $file; }
     ok( $x eq "hello\n", 'reading from <$_> works' );
     close $_;
 }
+
+{
+    $fqdb::_ = 'fqdb';
+    ok( $fqdb::_ eq 'fqdb', 'fully qualified $_ is not in main' );
+    ok( eval q/$fqdb::_/ eq 'fqdb', 'fully qualified, evaled $_ is not in main' );
+    package fqdb;
+    ::ok( $_ ne 'fqdb', 'unqualified $_ is in main' );
+    ::ok( q/$_/ ne 'fqdb', 'unqualified, evaled $_ is in main' );
+}