File: 104-map_type.t

package info (click to toggle)
perl 5.20.2-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 88,360 kB
  • sloc: perl: 555,131; ansic: 213,934; sh: 38,120; pascal: 8,783; cpp: 3,895; makefile: 2,392; xml: 2,325; yacc: 1,741
file content (69 lines) | stat: -rw-r--r-- 2,267 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests =>  7;
use ExtUtils::ParseXS;
use ExtUtils::ParseXS::Utilities qw(
  map_type
);

my ($self, $type, $varname);
my ($result, $expected);

$self = ExtUtils::ParseXS->new;

$type = 'struct DATA *';
$varname = 'RETVAL';
$self->{RetainCplusplusHierarchicalTypes} = 0;
$expected = "$type\t$varname";
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );

$type = 'Crypt::Shark';
$varname = undef;
$self->{RetainCplusplusHierarchicalTypes} = 0;
$expected = 'Crypt__Shark';
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, undef, <$self->{RetainCplusplusHierarchicalTypes}>" );

$type = 'Crypt::Shark';
$varname = undef;
$self->{RetainCplusplusHierarchicalTypes} = 1;
$expected = 'Crypt::Shark';
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, undef, <$self->{RetainCplusplusHierarchicalTypes}>" );

$type = 'Crypt::TC18';
$varname = 'RETVAL';
$self->{RetainCplusplusHierarchicalTypes} = 0;
$expected = "Crypt__TC18\t$varname";
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );

$type = 'Crypt::TC18';
$varname = 'RETVAL';
$self->{RetainCplusplusHierarchicalTypes} = 1;
$expected = "Crypt::TC18\t$varname";
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );

$type = 'array(alpha,beta) gamma';
$varname = 'RETVAL';
$self->{RetainCplusplusHierarchicalTypes} = 0;
$expected = "alpha *\t$varname";
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );

$type = '(*)';
$varname = 'RETVAL';
$self->{RetainCplusplusHierarchicalTypes} = 0;
$expected = "(* $varname )";
$result = map_type($self, $type, $varname);
is( $result, $expected,
    "Got expected map_type for <$type>, <$varname>, <$self->{RetainCplusplusHierarchicalTypes}>" );