Debian Codegraph @

dist/ExtUtils-ParseXS/t/104-map_type.t

raw
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Test::More tests => 7;
5 use ExtUtils::ParseXS;
6 use ExtUtils::ParseXS::Utilities qw(
7 map_type
8 );
9
10 my ($self, $type, $varname);
11 my ($result, $expected);
12
13 $self = ExtUtils::ParseXS->new;
14
15 $type = 'struct DATA *';
16 $varname = 'RETVAL';
17 $self->{RetainCplusplusHierarchicalTypes} = 0;
18 $expected = "$type\t$varname";
19 $result = map_type($self, $type, $varname);
20 is( $result, $expected,
21 "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );
22
23 $type = 'Crypt::Shark';
24 $varname = undef;
25 $self->{RetainCplusplusHierarchicalTypes} = 0;
26 $expected = 'Crypt__Shark';
27 $result = map_type($self, $type, $varname);
28 is( $result, $expected,
29 "Got expected map_type for <$type>, undef, <$self->{RetainCplusplusHierarchicalTypes}>" );
30
31 $type = 'Crypt::Shark';
32 $varname = undef;
33 $self->{RetainCplusplusHierarchicalTypes} = 1;
34 $expected = 'Crypt::Shark';
35 $result = map_type($self, $type, $varname);
36 is( $result, $expected,
37 "Got expected map_type for <$type>, undef, <$self->{RetainCplusplusHierarchicalTypes}>" );
38
39 $type = 'Crypt::TC18';
40 $varname = 'RETVAL';
41 $self->{RetainCplusplusHierarchicalTypes} = 0;
42 $expected = "Crypt__TC18\t$varname";
43 $result = map_type($self, $type, $varname);
44 is( $result, $expected,
45 "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );
46
47 $type = 'Crypt::TC18';
48 $varname = 'RETVAL';
49 $self->{RetainCplusplusHierarchicalTypes} = 1;
50 $expected = "Crypt::TC18\t$varname";
51 $result = map_type($self, $type, $varname);
52 is( $result, $expected,
53 "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );
54
55 $type = 'array(alpha,beta) gamma';
56 $varname = 'RETVAL';
57 $self->{RetainCplusplusHierarchicalTypes} = 0;
58 $expected = "alpha *\t$varname";
59 $result = map_type($self, $type, $varname);
60 is( $result, $expected,
61 "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );
62
63 $type = '(*)';
64 $varname = 'RETVAL';
65 $self->{RetainCplusplusHierarchicalTypes} = 0;
66 $expected = "(* $varname )";
67 $result = map_type($self, $type, $varname);
68 is( $result, $expected,
69 "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );