Sha256: 0b0c78548aac3da4cf17d46f1ef003db346b33b0605917e2f99c6d964a85e0ed

Contents?: true

Size: 1.32 KB

Versions: 82

Compression:

Stored size: 1.32 KB

Contents

exercise: Clock
version: 1
methods: time add-minutes
plan: 54
tests: |
  for @($c-data<cases>) {
    for @(.<cases>) -> $case {
      given $case<property> {
        when 'create' {
          is ::($exercise).new(hour => $case<hour>, minute => $case<minute>).?time, |$case<expected description>;
        }
        when 'add' {
          my $clock = ::($exercise).new(hour => $case<hour>, minute => $case<minute>);
          $clock.?add-minutes($case<add>);
          is $clock.?time, |$case<expected description>;
        }
        when 'equal' {
          is ::($exercise).new(hour => $case<clock1><hour>, minute => $case<clock1><minute>).?time eq
             ::($exercise).new(hour => $case<clock2><hour>, minute => $case<clock2><minute>).?time,
             |$case<expected description>;
        }
        when %*ENV<EXERCISM>.so { bail-out "no case for property '$case<property>'" }
      }
    }
  }
  
  todo 'optional test' unless %*ENV<EXERCISM>;
  is ::($exercise).new(:0hour,:0minute).?add-minutes(65).?time, '01:05', 'add-minutes method can be chained';

unit: class
example: |
  has Int:D $.hour = 0;
  has Int:D $.minute = 0;
  
  method time {
    sprintf '%02d:%02d', ($!hour + $!minute div 60) % 24, $!minute % 60;
  }
  
  method add-minutes (Int:D $min) {
    $!minute += $min and return self;
  }
stub: |
  has $.hour;
  has $.minute;

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
trackler-2.2.1.53 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.52 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.51 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.50 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.49 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.48 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.47 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.46 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.45 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.44 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.43 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.42 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.41 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.40 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.39 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.38 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.37 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.36 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.35 tracks/perl6/exercises/clock/example.yaml
trackler-2.2.1.34 tracks/perl6/exercises/clock/example.yaml