1#!/usr/bin/perl 2use strict; 3use warnings; 4use Test::More tests => 7; 5use ExtUtils::ParseXS; 6use ExtUtils::ParseXS::Utilities qw( 7 map_type 8); 9 10my ($self, $type, $varname); 11my ($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); 20is( $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); 28is( $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); 36is( $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); 44is( $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); 52is( $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); 60is( $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); 68is( $result, $expected, 69 "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" ); 70