Sidef/Types/Glob/Stat.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 47 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
all
2.0
parent
2.0
CRAP 2.0
1 package Sidef::Types::Glob::Stat;
2  
3 use utf8;
4 use 5.016;
5  
6 use parent qw(
7 Sidef::Object::Object
8 );
9  
10 sub new {
11 my (undef, %opt) = @_;
12  
13 bless {
14 obj => $opt{obj},
15 stat => Sidef::Types::Array::Array->new([map { Sidef::Types::Number::Number->new($_) } @{$opt{stat}}]),
16 },
17 __PACKAGE__;
18 }
19  
20 {
21 no strict 'refs';
22  
23 # The order matters!
24 my @names = qw(dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks);
25  
26 foreach my $i (0 .. $#names) {
27 *{__PACKAGE__ . '::' . $names[$i]} = sub {
28 $_[0]{stat}[$i];
29 };
30 }
31 }
32  
33 sub all {
34 Sidef::Types::Array::Array->new(@{$_[0]{stat}});
35 }
36  
37 sub parent {
38 $_[0]{obj};
39 }
40  
41 sub stat {
42 my ($self, $arg, $obj) = @_;
43 $self->new(stat => [stat($arg)], obj => $obj);
44 }
45  
46 sub lstat {
47 my ($self, $arg, $obj) = @_;
48 $self->new(stat => [lstat($arg)], obj => $obj);
49 }
50  
51 1