Sidef/Module/OO.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 14 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 / 55 CC 7 SCAR 35.1
CC
7
Cov
0%
AUTOLOAD
56.0
__NEW__
2.0
DESTROY
2.0
CRAP 33.5
1 package Sidef::Module::OO;
2  
3 use utf8;
4 use 5.016;
5 our $AUTOLOAD;
6  
7 use overload q{""} => sub {
8 my ($self) = @_;
9 overload::StrVal($self->{module}) ? "$self->{module}" : $self;
10 };
11  
12 sub __NEW__ {
13 my (undef, $module) = @_;
14 bless {module => $module}, __PACKAGE__;
15 }
16  
17 sub DESTROY {
18 return;
19 }
20  
21 sub AUTOLOAD {
22 my ($self, @arg) = @_;
23  
24 my ($method) = ($AUTOLOAD =~ /^.*[^:]::(.*)$/);
25  
26 my @args = (
27 @arg
28 ? (map { (ref($_) eq __PACKAGE__) ? $_->{module} : (index(ref($_), 'Sidef::') == 0) ? $_->get_value : $_ } @arg)
29 : ()
30 );
31  
32 my $multi_values = wantarray;
33  
34 my @results = do {
35 local *UNIVERSAL::AUTOLOAD;
36 $multi_values ? ($self->{module}->$method(@args)) : (scalar $self->{module}->$method(@args));
37 };
38  
39 $multi_values // return;
40  
41 @results = map { Sidef::Types::Perl::Perl->to_sidef($_) } @results;
42  
43 if (@results > 1) {
44 return ($multi_values ? @results : Sidef::Types::Array::Array->new(\@results));
45 }
46  
47 $results[0];
48 }
49  
50 1