[perl #39739] TODO test for Exporter respecting warning handlers
authorTony Cook <tony@develop-help.com>
Thu, 18 Jul 2013 06:02:29 +0000 (16:02 +1000)
committerTony Cook <tony@develop-help.com>
Fri, 26 Jul 2013 00:59:05 +0000 (10:59 +1000)
MANIFEST
dist/Exporter/t/warn.t [new file with mode: 0644]

index e7e153c..77b71fc 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2975,6 +2975,7 @@ dist/Env/t/env.t          See if Env works
 dist/Exporter/lib/Exporter/Heavy.pm    Complicated routines for Exporter
 dist/Exporter/lib/Exporter.pm          Exporter base class
 dist/Exporter/t/Exporter.t             See if Exporter works
+dist/Exporter/t/warn.t                 See if Exporter respects warning handlers
 dist/ExtUtils-CBuilder/Changes         EU-CB change log
 dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm           Base class for ExtUtils::CBuilder methods
 dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/aix.pm   CBuilder methods for AIX
diff --git a/dist/Exporter/t/warn.t b/dist/Exporter/t/warn.t
new file mode 100644 (file)
index 0000000..49a109c
--- /dev/null
@@ -0,0 +1,39 @@
+#!perl -w
+
+# Can't use Test::Simple/More, they depend on Exporter.
+my $test;
+sub ok ($;$) {
+    my($ok, $name) = @_;
+
+    # You have to do it this way or VMS will get confused.
+    printf "%sok %d%s\n", ($ok ? '' : 'not '), $test,
+      (defined $name ? " - $name" : '');
+
+    printf "# Failed test at line %d\n", (caller)[2] unless $ok;
+
+    $test++;
+    return $ok;
+}
+
+
+BEGIN {
+    $test = 1;
+    print "1..2\n";
+    require Exporter;
+    ok( 1, 'Exporter compiled' );
+}
+
+package Foo;
+Exporter->import("import");
+@EXPORT_OK = "bar";
+
+package main;
+
+{ # [perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
+    my @warn;
+
+    local $SIG{__WARN__} = sub { push @warn, join "", @_ };
+    eval { Foo->import(":quux") };
+    ok(grep(/"quux" is not defined/, @warn), "# TODO warnings captured");
+}
+