Commit | Line | Data |
---|---|---|
297f4492 S |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | use Test::More tests => 5; | |
7320491e | 6 | use ExtUtils::Typemaps; |
297f4492 S |
7 | use File::Spec; |
8 | use File::Temp; | |
9 | ||
10 | my $datadir = -d 't' ? File::Spec->catdir(qw/t data/) : 'data'; | |
11 | ||
12 | sub slurp { | |
13 | my $file = shift; | |
14 | open my $fh, '<', $file | |
15 | or die "Cannot open file '$file' for reading: $!"; | |
16 | local $/ = undef; | |
17 | return <$fh>; | |
18 | } | |
19 | ||
20 | my $first_typemap_file = File::Spec->catfile($datadir, 'simple.typemap'); | |
21 | my $second_typemap_file = File::Spec->catfile($datadir, 'other.typemap'); | |
22 | my $combined_typemap_file = File::Spec->catfile($datadir, 'combined.typemap'); | |
23 | ||
24 | ||
25 | SCOPE: { | |
7320491e S |
26 | my $first = ExtUtils::Typemaps->new(file => $first_typemap_file); |
27 | isa_ok($first, 'ExtUtils::Typemaps'); | |
28 | my $second = ExtUtils::Typemaps->new(file => $second_typemap_file); | |
29 | isa_ok($second, 'ExtUtils::Typemaps'); | |
297f4492 S |
30 | |
31 | $first->merge(typemap => $second); | |
32 | ||
33 | is($first->as_string(), slurp($combined_typemap_file), "merging produces expected output"); | |
34 | } | |
35 | ||
36 | SCOPE: { | |
7320491e S |
37 | my $first = ExtUtils::Typemaps->new(file => $first_typemap_file); |
38 | isa_ok($first, 'ExtUtils::Typemaps'); | |
297f4492 S |
39 | my $second_str = slurp($second_typemap_file); |
40 | ||
41 | $first->add_string(string => $second_str); | |
42 | ||
43 | is($first->as_string(), slurp($combined_typemap_file), "merging (string) produces expected output"); | |
44 | } |