This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Lose now obsolete process_single_typemap()
[perl5.git] / dist / ExtUtils-ParseXS / t / 106-process_typemaps.t
CommitLineData
bb5e8eb4
JK
1#!/usr/bin/perl
2use strict;
3use warnings;
4use Carp;
5use Cwd;
6use File::Spec;
7use File::Temp qw( tempdir );
9b58169a 8use Test::More tests => 2;
bb5e8eb4
JK
9use lib qw( lib );
10use ExtUtils::ParseXS::Utilities qw(
11 process_typemaps
bb5e8eb4
JK
12);
13
14my $startdir = cwd();
15{
16 my ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref);
17 my $typemap = 'typemap';
18 my $tdir = tempdir( CLEANUP => 1 );
19 chdir $tdir or croak "Unable to change to tempdir for testing";
20 eval {
21 ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref)
22 = process_typemaps( $typemap, $tdir );
23 };
24 like( $@, qr/Can't find $typemap in $tdir/, #'
25 "Got expected result for no typemap in current directory" );
26 chdir $startdir;
27}
28
29{
30 my ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref);
31 my $typemap = [ qw( pseudo typemap ) ];
32 my $tdir = tempdir( CLEANUP => 1 );
33 chdir $tdir or croak "Unable to change to tempdir for testing";
34 open my $IN, '>', 'typemap' or croak "Cannot open for writing";
35 print $IN "\n";
36 close $IN or croak "Cannot close after writing";
37 eval {
38 ($type_kind_ref, $proto_letter_ref, $input_expr_ref, $output_expr_ref)
39 = process_typemaps( $typemap, $tdir );
40 };
41 like( $@, qr/Can't find pseudo in $tdir/, #'
42 "Got expected result for no typemap in current directory" );
43 chdir $startdir;
44}
45