This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test perl #4760
[perl5.git] / t / op / magic.t
index 03487b0..3fb1ea1 100644 (file)
@@ -5,7 +5,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 171);
+    plan (tests => 177);
 }
 
 # Test that defined() returns true for magic variables created on the fly,
@@ -20,6 +20,7 @@ BEGIN {
        SIG ^OPEN ^TAINT ^UNICODE ^UTF8LOCALE ^WARNING_BITS 1 2 3 4 5 6 7 8
        9 42 & ` ' : ? ! _ - [ ^ ~ = % . ( ) < > \ / $ | + ; ] ^A ^C ^D
        ^E ^F ^H ^I ^L ^N ^O ^P ^S ^T ^V ^W ^UTF8CACHE ::12345 main::98732
+       ^LAST_FH
     )) {
        my $v = $_;
        # avoid using any global vars here:
@@ -54,7 +55,6 @@ $Is_VMS      = $^O eq 'VMS';
 $Is_Dos      = $^O eq 'dos';
 $Is_os2      = $^O eq 'os2';
 $Is_Cygwin   = $^O eq 'cygwin';
-$Is_MPE      = $^O eq 'mpeix';         
 $Is_BeOS     = $^O eq 'beos';
 
 $PERL = $ENV{PERL}
@@ -65,10 +65,17 @@ $PERL = $ENV{PERL}
 
 sub env_is {
     my ($key, $val, $desc) = @_;
+
+    use open IN => ":raw";
     if ($Is_MSWin32) {
         # cmd.exe will echo 'variable=value' but 4nt will echo just the value
         # -- Nikola Knezevic
-        like `set $key`, qr/^(?:\Q$key\E=)?\Q$val\E$/, $desc;
+       require Win32;
+       my $cp = Win32::GetConsoleOutputCP();
+       Win32::SetConsoleOutputCP(Win32::GetACP());
+        (my $set = `set $key`) =~ s/\r\n$/\n/;
+       Win32::SetConsoleOutputCP($cp);
+        like $set, qr/^(?:\Q$key\E=)?\Q$val\E$/, $desc;
     } elsif ($Is_VMS) {
         is `write sys\$output f\$trnlnm("\Q$key\E")`, "$val\n", $desc;
     } else {
@@ -99,7 +106,7 @@ close FOO; # just mention it, squelch used-only-once
 
 SKIP: {
     skip('SIGINT not safe on this platform', 5)
-       if $Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE;
+       if $Is_MSWin32 || $Is_NetWare || $Is_Dos;
   # the next tests are done in a subprocess because sh spits out a
   # newline onto stderr when a child process kills itself with SIGINT.
   # We use a pipe rather than system() because the VMS command buffer
@@ -309,7 +316,7 @@ $^X = Cygwin::win_to_posix_path(Cygwin::posix_to_win_path($^X, 1));
 $0 = Cygwin::win_to_posix_path(Cygwin::posix_to_win_path($0, 1));
 EOX
     }
-    if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') {  # no shebang
+    if ($^O eq 'os390' or $^O eq 'posix-bc') {  # no shebang
        $headmaybe = <<EOH ;
     eval 'exec ./perl -S \$0 \${1+"\$\@"}'
         if 0;
@@ -597,6 +604,25 @@ SKIP: {
     }
 }
 
+# ${^LAST_FH}
+() = tell STDOUT;
+is ${^LAST_FH}, \*STDOUT, '${^LAST_FH} after tell';
+() = tell STDIN;
+is ${^LAST_FH}, \*STDIN, '${^LAST_FH} after another tell';
+{
+    my $fh = *STDOUT;
+    () = tell $fh;
+    is ${^LAST_FH}, \$fh, '${^LAST_FH} referencing lexical coercible glob';
+}
+# This also tests that ${^LAST_FH} is a weak reference:
+is ${^LAST_FH}, undef, '${^LAST_FH} is undef when PL_last_in_gv is NULL';
+
+
+# $|
+fresh_perl_is 'print $| = ~$|', "1\n", {switches => ['-l']}, 
+ '[perl #4760] print $| = ~$|';
+
+
 # ^^^^^^^^^ New tests go here ^^^^^^^^^
 
 SKIP: {