Make Cwd::fastcwd() return a tainted value.
[p5sagit/p5-mst-13.2.git] / ext / Cwd / t / taint.t
index 74e2d65..3f6aa52 100644 (file)
@@ -7,15 +7,18 @@ BEGIN {
 }
 
 use Cwd;
-use Test::More tests => 2;
-
-# The normal kill() trick is not portable.
-sub is_tainted { 
-    return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 };
-}
+use Test::More tests => 6;
+use Scalar::Util qw/tainted/;
 
 my $cwd;
 eval { $cwd = getcwd; };
-is( $@, '',                 'getcwd() does not explode under taint mode' );
-ok( is_tainted($cwd),       "its return value is tainted" );
+is( $@, '',            'getcwd() does not explode under taint mode' );
+ok( tainted($cwd),     "its return value is tainted" );
+
+eval { $cwd = cwd; };
+is( $@, '',            'cwd() does not explode under taint mode' );
+ok( tainted($cwd),     "its return value is tainted" );
 
+eval { $cwd = fastcwd; };
+is( $@, '',            'fastcwd() does not explode under taint mode' );
+ok( tainted($cwd),     "its return value is tainted" );