Sidef/Module/Func.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 51 CC 6 SCAR 31.7
CC
6
Cov
0%
AUTOLOAD
42.0
__NEW__
2.0
DESTROY
2.0
CRAP 23.8
1 package Sidef::Module::Func;
2  
3 use utf8;
4 use 5.016;
5 our $AUTOLOAD;
6  
7 sub __NEW__ {
8 my (undef, $module) = @_;
9 bless {module => $module}, __PACKAGE__;
10 }
11  
12 sub DESTROY {
13 return;
14 }
15  
16 sub AUTOLOAD {
17 my ($self, @arg) = @_;
18  
19 my ($func) = ($AUTOLOAD =~ /^.*[^:]::(.*)$/);
20  
21 my @args = (
22 @arg
23 ? (map { (index(ref($_), 'Sidef::') == 0) ? $_->get_value : $_ } @arg)
24 : ()
25 );
26  
27 my $multi_values = wantarray;
28  
29 my @results = do {
30 local *UNIVERSAL::AUTOLOAD;
31 no strict 'refs';
32 $multi_values ? (($self->{module} . '::' . $func)->(@args)) : scalar(($self->{module} . '::' . $func)->(@args));
33 };
34  
35 $multi_values // return;
36  
37 @results = map { Sidef::Types::Perl::Perl->to_sidef($_) } @results;
38  
39 if (@results > 1) {
40 return ($multi_values ? @results : Sidef::Types::Array::Array->new(\@results));
41 }
42  
43 $results[0];
44 }
45  
46 1