[perl #68108] : also fix if/else constant folding
[p5sagit/p5-mst-13.2.git] / t / op / kill0.t
index 063c388..eadf15d 100644 (file)
@@ -14,7 +14,7 @@ BEGIN {
 
 use strict;
 
-plan tests => 2;
+plan tests => 5;
 
 ok( kill(0, $$), 'kill(0, $pid) returns true if $pid exists' );
 
@@ -29,3 +29,17 @@ for my $pid (1 .. $total) {
 # It is highly unlikely that all of the above PIDs are genuinely in use,
 # so $count should be less than $total.
 ok( $count < $total, 'kill(0, $pid) returns false if $pid does not exist' );
+
+# Verify that trying to kill a non-numeric PID is fatal
+my @bad_pids = (
+    [ undef , 'undef'         ],
+    [ ''    , 'empty string'  ],
+    [ 'abcd', 'alphabetic'    ],
+);
+
+for my $case ( @bad_pids ) {
+  my ($pid, $name) = @$case;
+  eval { kill 0, $pid };
+  like( $@, qr/^Can't kill a non-numeric process ID/, "dies killing $name pid");
+}
+