tracks/perl5/exercises/clock/clock.t in trackler-2.2.1.131 vs tracks/perl5/exercises/clock/clock.t in trackler-2.2.1.132

- old
+ new

@@ -1,57 +1,52 @@ #!/usr/bin/env perl use strict; use warnings; +use JSON::PP; use FindBin; use lib $FindBin::Bin; -use JSON::PP; +use Clock (); my $exercise = 'Clock'; -my $test_version = 1; -use Test::More tests => 57; +my $test_version = 2; +use Test::More tests => 53; -use_ok $exercise or BAIL_OUT; - my $exercise_version = $exercise->VERSION // 0; if ($exercise_version != $test_version) { warn "\nExercise version mismatch. Further tests may fail!" . "\n$exercise is v$exercise_version. " . "Test is v$test_version.\n"; BAIL_OUT if $ENV{EXERCISM}; } -my %subs; -foreach ( qw(new time add_minutes subtract_minutes) ) { - can_ok $exercise, $_; - $subs{$_} = $exercise->can($_); -} +can_ok $exercise, qw(new time add_minutes subtract_minutes); my $C_DATA = do { local $/; decode_json(<DATA>); }; foreach (@{$C_DATA->{cases}}) { foreach (@{$_->{cases}}) { if ($_->{property} eq 'create') { - is Clock->new($_->{input})->time, $_->{expected}, $_->{description}; + is($exercise->new($_->{input})->time, $_->{expected}, $_->{description}); } elsif ($_->{property} eq 'add' || $_->{property} eq 'subtract') { - my $clock = Clock->new({ + my $clock = $exercise->new({ hour => $_->{input}{hour}, minute => $_->{input}{minute}, }); if ($_->{property} eq 'subtract') { $clock->subtract_minutes($_->{input}{value}) } elsif ($_->{property} eq 'add' ) { $clock->add_minutes( $_->{input}{value}) } is $clock->time, $_->{expected}, $_->{description}; } elsif ($_->{property} eq 'equal') { ok $_->{expected} == - (Clock->new($_->{input}{clock1})->time eq Clock->new($_->{input}{clock2})->time), $_->{description}; + ($exercise->new($_->{input}{clock1})->time eq $exercise->new($_->{input}{clock2})->time), $_->{description}; } } } -is Clock->new({hour => 0, minute => 0})->add_minutes(65)->time, '01:05', 'add_minutes method can be chained'; -is Clock->new({hour => 0, minute => 0})->subtract_minutes(65)->time, '22:55', 'subtract_minutes method can be chained'; +is($exercise->new({hour => 0, minute => 0})->add_minutes(65)->time, '01:05', 'add_minutes method can be chained'); +is($exercise->new({hour => 0, minute => 0})->subtract_minutes(65)->time, '22:55', 'subtract_minutes method can be chained'); __DATA__ { "exercise": "clock", "version": "2.2.1",