1#!/usr/bin/perl -T
2use strict;
3use warnings;
4
5use Config;
6use Test::More $Config{ccflags} =~ /-DSILENT_NO_TAINT_SUPPORT/
7    ? ( skip_all => 'No taint support' ) : ( tests => 2 );
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
21my $taint_on = ! eval { no warnings; join('',values %ENV), kill 0; 1; };
22ok($taint_on, 'taint flag is set');
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
32