| 1 |
#!/usr/bin/perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Carp; |
| 5 |
use Cwd qw(cwd); |
| 6 |
use File::Temp qw( tempdir ); |
| 7 |
use Test::More tests => 2; |
| 8 |
use ExtUtils::ParseXS::Utilities qw( |
| 9 |
process_typemaps |
| 10 |
); |
| 11 |
|
| 12 |
my $startdir = cwd(); |
| 13 |
{ |
| 14 |
my ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref); |
| 15 |
my $typemap = 'typemap'; |
| 16 |
my $tdir = tempdir( CLEANUP => 1 ); |
| 17 |
chdir $tdir or croak "Unable to change to tempdir for testing"; |
| 18 |
eval { |
| 19 |
($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref) |
| 20 |
= process_typemaps( $typemap, $tdir ); |
| 21 |
}; |
| 22 |
like( $@, qr/Can't find \Q$typemap\E in \Q$tdir\E/, #' |
| 23 |
"Got expected result for no typemap in current directory" ); |
| 24 |
chdir $startdir; |
| 25 |
} |
| 26 |
|
| 27 |
{ |
| 28 |
my ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref); |
| 29 |
my $typemap = [ qw( pseudo typemap ) ]; |
| 30 |
my $tdir = tempdir( CLEANUP => 1 ); |
| 31 |
chdir $tdir or croak "Unable to change to tempdir for testing"; |
| 32 |
open my $IN, '>', 'typemap' or croak "Cannot open for writing"; |
| 33 |
print $IN "\n"; |
| 34 |
close $IN or croak "Cannot close after writing"; |
| 35 |
eval { |
| 36 |
($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref) |
| 37 |
= process_typemaps( $typemap, $tdir ); |
| 38 |
}; |
| 39 |
like( $@, qr/Can't find pseudo in \Q$tdir\E/, #' |
| 40 |
"Got expected result for no typemap in current directory" ); |
| 41 |
chdir $startdir; |
| 42 |
} |
| 43 |
|