summaryrefslogtreecommitdiff
path: root/dist/ExtUtils-ParseXS/t/110-assign_func_args.t
blob: 63d978417b5764800a743de6f5986a8ebe182946 (plain)
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
#!/usr/bin/perl
use strict;
use warnings;
use Carp;
use Cwd;
use File::Spec;
use File::Temp qw( tempdir );
use Test::More qw(no_plan); # tests =>  7;
use lib qw( lib );
use ExtUtils::ParseXS::Utilities qw(
    assign_func_args
);

#sub assign_func_args {
#  my ($self, $argsref, $class) = @_;
#  return join(", ", @func_args);

my ($self, @args, $class);
my ($func_args, $expected);

@args = qw( alpha beta gamma );
$self->{in_out}->{alpha} = 'OUT';
$expected = q|&alpha, beta, gamma|;
$func_args = assign_func_args($self, \@args, $class);
is( $func_args, $expected,
    "Got expected func_args: in_out true; class undefined" );

@args = ( 'My::Class', qw( beta gamma ) );
$self->{in_out}->{beta} = 'OUT';
$class = 'My::Class';
$expected = q|&beta, gamma|;
$func_args = assign_func_args($self, \@args, $class);
is( $func_args, $expected,
    "Got expected func_args: in_out true; class defined" );

@args = ( 'My::Class', qw( beta gamma ) );
$self->{in_out}->{beta} = '';
$class = 'My::Class';
$expected = q|beta, gamma|;
$func_args = assign_func_args($self, \@args, $class);
is( $func_args, $expected,
    "Got expected func_args: in_out false; class defined" );

@args = qw( alpha beta gamma );
$self->{in_out}->{alpha} = '';
$class = undef;
$expected = q|alpha, beta, gamma|;
$func_args = assign_func_args($self, \@args, $class);
is( $func_args, $expected,
    "Got expected func_args: in_out false; class undefined" );

pass("Passed all tests in $0");