Skip to content

Commit

Permalink
Switch from Moo to built-in class
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dango committed Sep 5, 2024
1 parent c4b636e commit 0f7d222
Show file tree
Hide file tree
Showing 35 changed files with 167 additions and 367 deletions.
4 changes: 2 additions & 2 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requires 'lib::gitroot';
requires 'Data::Dmp';
requires 'Moo';
requires 'Feature::Compat::Class';
requires 'lib::gitroot';
requires 'namespace::autoclean';
requires 'Path::Tiny';
requires 'Perl::Tidy';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
package BinarySearchTree;

use Moo;
use strict;
use warnings;
use experimental qw<signatures postderef postderef_qq>;
use Feature::Compat::Class;

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.26 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.26.3/x64/lib/site_perl/5.26.3/x86_64-linux /opt/hostedtoolcache/perl/5.26.3/x64/lib/site_perl/5.26.3 /opt/hostedtoolcache/perl/5.26.3/x64/lib/5.26.3/x86_64-linux /opt/hostedtoolcache/perl/5.26.3/x64/lib/5.26.3)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.26 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.22 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.22.4/x64/lib/site_perl/5.22.4/x86_64-linux /opt/hostedtoolcache/perl/5.22.4/x64/lib/site_perl/5.22.4 /opt/hostedtoolcache/perl/5.22.4/x64/lib/5.22.4/x86_64-linux /opt/hostedtoolcache/perl/5.22.4/x64/lib/5.22.4 .)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.22 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.24 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.24.4/x64/lib/site_perl/5.24.4/x86_64-linux /opt/hostedtoolcache/perl/5.24.4/x64/lib/site_perl/5.24.4 /opt/hostedtoolcache/perl/5.24.4/x64/lib/5.24.4/x86_64-linux /opt/hostedtoolcache/perl/5.24.4/x64/lib/5.24.4 .)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.24 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.30 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.30.3/x64/lib/site_perl/5.30.3/x86_64-linux /opt/hostedtoolcache/perl/5.30.3/x64/lib/site_perl/5.30.3 /opt/hostedtoolcache/perl/5.30.3/x64/lib/5.30.3/x86_64-linux /opt/hostedtoolcache/perl/5.30.3/x64/lib/5.30.3)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.30 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.38 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc entries checked: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.38.2/x64/lib/site_perl/5.38.2/x86_64-linux /opt/hostedtoolcache/perl/5.38.2/x64/lib/site_perl/5.38.2 /opt/hostedtoolcache/perl/5.38.2/x64/lib/5.38.2/x86_64-linux /opt/hostedtoolcache/perl/5.38.2/x64/lib/5.38.2)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.38 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.28 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.28.3/x64/lib/site_perl/5.28.3/x86_64-linux /opt/hostedtoolcache/perl/5.28.3/x64/lib/site_perl/5.28.3 /opt/hostedtoolcache/perl/5.28.3/x64/lib/5.28.3/x86_64-linux /opt/hostedtoolcache/perl/5.28.3/x64/lib/5.28.3)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.28 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.40 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc entries checked: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.40.0/x64/lib/site_perl/5.40.0/x86_64-linux /opt/hostedtoolcache/perl/5.40.0/x64/lib/site_perl/5.40.0 /opt/hostedtoolcache/perl/5.40.0/x64/lib/5.40.0/x86_64-linux /opt/hostedtoolcache/perl/5.40.0/x64/lib/5.40.0)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.40 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.32 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.32.1/x64/lib/site_perl/5.32.1/x86_64-linux /opt/hostedtoolcache/perl/5.32.1/x64/lib/site_perl/5.32.1 /opt/hostedtoolcache/perl/5.32.1/x64/lib/5.32.1/x86_64-linux /opt/hostedtoolcache/perl/5.32.1/x64/lib/5.32.1)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.32 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.20 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.20.3/x64/lib/site_perl/5.20.3/x86_64-linux /opt/hostedtoolcache/perl/5.20.3/x64/lib/site_perl/5.20.3 /opt/hostedtoolcache/perl/5.20.3/x64/lib/5.20.3/x86_64-linux /opt/hostedtoolcache/perl/5.20.3/x64/lib/5.20.3 .)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.20 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.36 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/binary-search-tree/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.36.3/x64/lib/site_perl/5.36.3/x86_64-linux /opt/hostedtoolcache/perl/5.36.3/x64/lib/site_perl/5.36.3 /opt/hostedtoolcache/perl/5.36.3/x64/lib/5.36.3/x86_64-linux /opt/hostedtoolcache/perl/5.36.3/x64/lib/5.36.3)

Check failure on line 4 in exercises/practice/binary-search-tree/.meta/solutions/lib/BinarySearchTree.pm

View workflow job for this annotation

GitHub Actions / Perl 5.36 on ubuntu-latest

BEGIN failed--compilation aborted

package BinarySearchTree::Node {
use Moo;
no warnings qw<experimental::signatures>;

has data => (
is => 'ro',
);
has [qw<left right>] => (
is => 'rw',
);

sub set ( $self, $data ) {
if ( $data > $self->data ) {
if ( $self->right ) {
$self->right->set($data);
}
else {
$self->right( BinarySearchTree::Node->new( data => $data ) );
}
}
elsif ( $self->left ) {
$self->left->set($data);
}
else {
$self->left( BinarySearchTree::Node->new( data => $data ) );
}
}
};
class BinarySearchTree;

has root => (
is => 'rw',
);
field $root : param;

sub add ( $self, $data ) {
$self->root->set($data);
method add ($data) {
$root->set($data);
}

sub sort ($self) {
method sort () {
my @sorted;
my $sub;
$sub = sub {
Expand All @@ -55,8 +26,31 @@ sub sort ($self) {
$sub->( $node->right );
}
};
$sub->( $self->root );
$sub->($root);
return [@sorted];
}

class BinarySearchTree::Node {
field $data : reader : param;
field $left : reader;
field $right : reader;

method set ($new_data) {
if ( $new_data > $data ) {
if ($right) {
$right->set($new_data);
}
else {
$right = BinarySearchTree::Node->new( data => $new_data );
}
}
elsif ($left) {
$left->set($new_data);
}
else {
$left = BinarySearchTree::Node->new( data => $new_data );
}
}
}

1;
92 changes: 39 additions & 53 deletions exercises/practice/binary-search-tree/.meta/template-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,15 @@ properties:
);
END
moo: 1
class: true
example: |-
package BinarySearchTree::Node {
use Moo;
no warnings qw<experimental::signatures>;
field $root :param;
has data => (
is => 'ro',
);
has [qw<left right>] => (
is => 'rw',
);
sub set ($self, $data) {
if ($data > $self->data) {
if ($self->right) {
$self->right->set($data);
}
else {
$self->right(BinarySearchTree::Node->new(data => $data));
}
}
elsif ($self->left) {
$self->left->set($data);
}
else {
$self->left(BinarySearchTree::Node->new(data => $data));
}
}
};
has root => (
is => 'rw',
);
sub add ($self, $data) {
$self->root->set($data);
method add ($data) {
$root->set($data);
}
sub sort ($self) {
method sort () {
my @sorted;
my $sub;
$sub = sub {
Expand All @@ -68,30 +37,47 @@ example: |-
$sub->($node->right);
}
};
$sub->($self->root);
$sub->($root);
return [@sorted];
}
stub: |-
package BinarySearchTree::Node {
use Moo;
class BinarySearchTree::Node {
field $data :reader :param;
field $left :reader;
field $right :reader;
has data => (
is => 'ro',
);
has [qw<left right>] => (
is => 'rw',
);
};
method set ($new_data) {
if ($new_data > $data) {
if ($right) {
$right->set($new_data);
}
else {
$right = BinarySearchTree::Node->new(data => $new_data);
}
}
elsif ($left) {
$left->set($new_data);
}
else {
$left = BinarySearchTree::Node->new(data => $new_data);
}
}
}
has root => (
is => 'rw',
);
sub add ($self) {
# $self->root contains the initial node.
stub: |-
field $root :param;
method add () {
# $root contains the initial node.
}
sub sort ($self) {
method sort () {
return [];
}
class BinarySearchTree::Node {
field $data :reader :param;
field $left :reader;
field $right :reader;
}
5 changes: 0 additions & 5 deletions exercises/practice/binary-search-tree/cpanfile

This file was deleted.

31 changes: 12 additions & 19 deletions exercises/practice/binary-search-tree/lib/BinarySearchTree.pm
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
package BinarySearchTree;

use v5.40;
use Moo;

package BinarySearchTree::Node {
use Moo;
use experimental qw<class>;

has data => (
is => 'ro',
);
has [qw<left right>] => (
is => 'rw',
);
};
class BinarySearchTree;

has root => (
is => 'rw',
);
field $root : param;

sub add ($self) {
method add () {

# $self->root contains the initial node.
# $root contains the initial node.
}

sub sort ($self) {
method sort () {
return [];
}

class BinarySearchTree::Node {
field $data : reader : param;
field $left : reader;
field $right : reader;
}

1;
1 change: 0 additions & 1 deletion exercises/practice/clock/.meta/solutions/cpanfile

This file was deleted.

37 changes: 20 additions & 17 deletions exercises/practice/clock/.meta/solutions/lib/Clock.pm
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
package Clock;

use Moo;
use strict;
use warnings;
use experimental qw<signatures postderef postderef_qq>;
use Feature::Compat::Class;

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.26 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.26.3/x64/lib/site_perl/5.26.3/x86_64-linux /opt/hostedtoolcache/perl/5.26.3/x64/lib/site_perl/5.26.3 /opt/hostedtoolcache/perl/5.26.3/x64/lib/5.26.3/x86_64-linux /opt/hostedtoolcache/perl/5.26.3/x64/lib/5.26.3)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.26 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.22 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.22.4/x64/lib/site_perl/5.22.4/x86_64-linux /opt/hostedtoolcache/perl/5.22.4/x64/lib/site_perl/5.22.4 /opt/hostedtoolcache/perl/5.22.4/x64/lib/5.22.4/x86_64-linux /opt/hostedtoolcache/perl/5.22.4/x64/lib/5.22.4 .)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.22 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.24 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.24.4/x64/lib/site_perl/5.24.4/x86_64-linux /opt/hostedtoolcache/perl/5.24.4/x64/lib/site_perl/5.24.4 /opt/hostedtoolcache/perl/5.24.4/x64/lib/5.24.4/x86_64-linux /opt/hostedtoolcache/perl/5.24.4/x64/lib/5.24.4 .)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.24 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.30 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.30.3/x64/lib/site_perl/5.30.3/x86_64-linux /opt/hostedtoolcache/perl/5.30.3/x64/lib/site_perl/5.30.3 /opt/hostedtoolcache/perl/5.30.3/x64/lib/5.30.3/x86_64-linux /opt/hostedtoolcache/perl/5.30.3/x64/lib/5.30.3)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.30 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.38 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc entries checked: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.38.2/x64/lib/site_perl/5.38.2/x86_64-linux /opt/hostedtoolcache/perl/5.38.2/x64/lib/site_perl/5.38.2 /opt/hostedtoolcache/perl/5.38.2/x64/lib/5.38.2/x86_64-linux /opt/hostedtoolcache/perl/5.38.2/x64/lib/5.38.2)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.38 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.28 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.28.3/x64/lib/site_perl/5.28.3/x86_64-linux /opt/hostedtoolcache/perl/5.28.3/x64/lib/site_perl/5.28.3 /opt/hostedtoolcache/perl/5.28.3/x64/lib/5.28.3/x86_64-linux /opt/hostedtoolcache/perl/5.28.3/x64/lib/5.28.3)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.28 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.40 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc entries checked: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.40.0/x64/lib/site_perl/5.40.0/x86_64-linux /opt/hostedtoolcache/perl/5.40.0/x64/lib/site_perl/5.40.0 /opt/hostedtoolcache/perl/5.40.0/x64/lib/5.40.0/x86_64-linux /opt/hostedtoolcache/perl/5.40.0/x64/lib/5.40.0)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.40 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.32 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.32.1/x64/lib/site_perl/5.32.1/x86_64-linux /opt/hostedtoolcache/perl/5.32.1/x64/lib/site_perl/5.32.1 /opt/hostedtoolcache/perl/5.32.1/x64/lib/5.32.1/x86_64-linux /opt/hostedtoolcache/perl/5.32.1/x64/lib/5.32.1)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.32 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.20 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.20.3/x64/lib/site_perl/5.20.3/x86_64-linux /opt/hostedtoolcache/perl/5.20.3/x64/lib/site_perl/5.20.3 /opt/hostedtoolcache/perl/5.20.3/x64/lib/5.20.3/x86_64-linux /opt/hostedtoolcache/perl/5.20.3/x64/lib/5.20.3 .)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.20 on ubuntu-latest

BEGIN failed--compilation aborted

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.36 on ubuntu-latest

Can't locate Feature/Compat/Class.pm in @inc (you may need to install the Feature::Compat::Class module) (@inc contains: /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../lib /home/runner/work/perl5/perl5/exercises/practice/clock/.meta/solutions/t/../local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5 /home/runner/work/perl5/perl5/local/lib/perl5/x86_64-linux /home/runner/work/_actions/shogo82148/actions-setup-perl/87c3ad5232e6c1b59da33bfde4fb24b0482901f1/scripts/lib /opt/hostedtoolcache/perl/5.36.3/x64/lib/site_perl/5.36.3/x86_64-linux /opt/hostedtoolcache/perl/5.36.3/x64/lib/site_perl/5.36.3 /opt/hostedtoolcache/perl/5.36.3/x64/lib/5.36.3/x86_64-linux /opt/hostedtoolcache/perl/5.36.3/x64/lib/5.36.3)

Check failure on line 4 in exercises/practice/clock/.meta/solutions/lib/Clock.pm

View workflow job for this annotation

GitHub Actions / Perl 5.36 on ubuntu-latest

BEGIN failed--compilation aborted

class Clock;

use POSIX ();
use POSIX qw<floor>;

has [qw(hour minute)] => (
is => 'rwp',
default => 0,
);
field $hour : reader : param = 0;
field $minute : reader : param = 0;

sub time ($self) {
return sprintf '%02d:%02d', $self->hour, $self->minute;
method time {
return sprintf '%02d:%02d', $hour, $minute;
}

sub add_minutes ( $self, $amount ) {
$self->_set_minute( $self->minute + $amount );
return $self->BUILD;
method add_minutes ($amount) {
return $self->_set_time( $hour * 60 + $minute + $amount );
}

sub subtract_minutes ( $self, $amount ) {
method subtract_minutes ($amount) {
return $self->add_minutes( -$amount );
}

sub BUILD ( $self, @ ) {
$self->_set_hour( ( $self->hour + POSIX::floor( $self->minute / 60 ) ) % 24 );
$self->_set_minute( $self->minute % 60 );
ADJUST {
$self->_set_time( $hour * 60 + $minute );
}

method _set_time ($amount) {
$hour = floor( $amount / 60 ) % 24;
$minute = $amount % 60;
return $self;
}

Expand Down
Loading

0 comments on commit 0f7d222

Please sign in to comment.