Test uninit warnings for undef XS cmp retvals
authorFather Chrysostomos <sprout@cpan.org>
Sat, 15 Oct 2011 21:08:31 +0000 (14:08 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 15 Oct 2011 21:24:27 +0000 (14:24 -0700)
ext/XS-APItest/APItest.xs
ext/XS-APItest/t/sort.t

index f5aa9bd..646d821 100644 (file)
@@ -3254,6 +3254,13 @@ CODE:
 OUTPUT:
     RETVAL
 
+SV *
+xs_cmp_undef(SV *a, SV *b)
+CODE:
+    RETVAL = &PL_sv_undef;
+OUTPUT:
+    RETVAL
+
 
 MODULE = XS::APItest PACKAGE = XS::APItest::AUTOLOADtest
 
index c7f0c71..3008742 100644 (file)
@@ -2,9 +2,16 @@
 
 use strict;
 use warnings;
-use Test::More tests => 1;
+use Test::More tests => 2;
 
 use XS::APItest;
 
 is join("", sort xs_cmp split//, '1415926535'), '1135559246',
   'sort treats XS cmp routines as having implicit ($$)';
+{
+  my $w;
+  local $SIG{__WARN__} = sub { $w .= shift };
+  () = sort xs_cmp_undef 1,2;
+  like $w, qr/^Use of uninitialized value in sort at /,
+   'warning about undef retval from cmp routine mentions sort';
+}