This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Module-Metadata from version 1.000026 to 1.000027
[perl5.git] / cpan / Module-Metadata / t / taint.t
CommitLineData
979f1f2b
SH
1#!/usr/bin/perl -T
2use strict;
3use warnings;
4
72b8c7a2
SH
5use Config;
6use Test::More $Config{ccflags} =~ /-DSILENT_NO_TAINT_SUPPORT/
7 ? ( skip_all => 'No taint support' ) : ( tests => 2 );
979f1f2b
SH
8use Module::Metadata;
9use Carp 'croak';
10
11# stolen liberally from Class-Tiny/t/lib/TestUtils.pm - thanks xdg!
12sub exception(&) {
13 my $code = shift;
14 my $success = eval { $code->(); 1 };
15 my $err = $@;
16 return undef if $success; # original returned ''
17 croak "Execution died, but the error was lost" unless $@;
18 return $@;
19}
20
153b7a01
CBW
21my $taint_on = ! eval { no warnings; join('',values %ENV), kill 0; 1; };
22ok($taint_on, 'taint flag is set');
979f1f2b
SH
23
24# without the fix, we get:
25# Insecure dependency in eval while running with -T switch at lib/Module/Metadata.pm line 668, <GEN0> line 15.
26is(
27 exception { Module::Metadata->new_from_module( "Module::Metadata" )->version },
28 undef,
29 'no exception',
30);
31