Change 18071 by rgs@rgs-home on 2002/10/28 21:57:25

        Subject: RE: [PATCH] Warning on pararameterless 'use IO' and doc update
        From: "Paul Marquess" <[EMAIL PROTECTED]>
        Date: Mon, 28 Oct 2002 12:53:52 -0000
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/ext/IO/IO.pm#10 edit
.... //depot/perl/ext/IO/lib/IO/t/IO.t#2 edit

Differences ...

==== //depot/perl/ext/IO/IO.pm#10 (text) ====
Index: perl/ext/IO/IO.pm
--- perl/ext/IO/IO.pm#9~18060~  Thu Oct 24 16:54:50 2002
+++ perl/ext/IO/IO.pm   Mon Oct 28 13:57:25 2002
@@ -4,17 +4,18 @@
 
 use XSLoader ();
 use Carp;
+use strict;
+use warnings;
 
-$VERSION = "1.20";
+our $VERSION = "1.20";
 XSLoader::load 'IO', $VERSION;
 
 sub import {
     shift;
-    if (@_ == 0) {
-       require warnings;
-       warnings::warn('deprecated', qq{parameterless "use IO" deprecated})
-               if warnings::enabled('deprecated');
-    }
+
+    warnings::warnif('deprecated', qq{parameterless "use IO" deprecated})
+        if @_ == 0 ;
+    
     my @l = @_ ? @_ : qw(Handle Seekable File Pipe Socket Dir);
 
     eval join("", map { "require IO::" . (/(\w+)/)[0] . ";\n" } @l)

==== //depot/perl/ext/IO/lib/IO/t/IO.t#2 (text) ====
Index: perl/ext/IO/lib/IO/t/IO.t
--- perl/ext/IO/lib/IO/t/IO.t#1~18061~  Thu Oct 24 17:13:07 2002
+++ perl/ext/IO/lib/IO/t/IO.t   Mon Oct 28 13:57:25 2002
@@ -9,7 +9,7 @@
 use strict;
 use File::Path;
 use File::Spec;
-use Test::More tests => 13;
+use Test::More tests => 18;
 
 {
        local $INC{'XSLoader.pm'} = 1;
@@ -30,7 +30,47 @@
 my @default = map { "IO/$_.pm" } qw( Handle Seekable File Pipe Socket Dir );
 delete @INC{ @default };
 
-IO->import();
+my $warn = '' ;
+local $SIG{__WARN__} = sub { $warn = "@_" } ;
+
+{
+    no warnings ;
+    IO->import();
+    is( $warn, '', "... import default, should not warn");
+    $warn = '' ;
+}
+
+{
+    local $^W = 0;
+    IO->import();
+    is( $warn, '', "... import default, should not warn");
+    $warn = '' ;
+}
+
+{
+    local $^W = 1;
+    IO->import();
+    like( $warn, qr/^parameterless "use IO" deprecated at/, 
+              "... import default, should warn");
+    $warn = '' ;
+}
+
+{
+    use warnings 'deprecated' ;
+    IO->import(); 
+    like( $warn, qr/^parameterless "use IO" deprecated at/, 
+              "... import default, should warn");
+    $warn = '' ;
+}
+
+{
+    use warnings ;
+    IO->import();
+    like( $warn, qr/^parameterless "use IO" deprecated at/, 
+              "... import default, should warn");
+    $warn = '' ;
+}
+
 foreach my $default (@default)
 {
        ok( exists $INC{ $default }, "... import should default load $default" );
End of Patch.

Reply via email to