Sha256: 680cab8ce15a51d7391a09940cab1f8668ddbf9f976ba0f03669cd3d9186ea93

Contents?: true

Size: 1.09 KB

Versions: 83

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env perl6
use v6;
use Test;
use lib $?FILE.IO.dirname;
use Accumulate;
plan 6;

my Version:D $version = v2;

if Accumulate.^ver !~~ $version {
  warn "\nExercise version mismatch. Further tests may fail!"
    ~ "\nAccumulate is {Accumulate.^ver.gist}. "
    ~ "Test is {$version.gist}.\n";
}

is-deeply accumulate([ ], sub {}),
          [ ],
          'test empty';
is-deeply accumulate([1, 2, 3, 4, 5], sub { @_[0] * @_[0] }),
          [1, 4, 9, 16, 25],
          'raise to 2';
is-deeply accumulate([10, 17, 23], sub { [ (@_[0] / 7).truncate, (@_[0] % 7).truncate ] }),
          [[1, 3], [2, 3], [3, 2] ],
          'divmod';
is-deeply accumulate(['hello', 'exercism'], sub { @_[0].uc }),
          ['HELLO', 'EXERCISM'],
          'capitalize';
is-deeply accumulate(['a', 'b', 'c' ], sub ($inp) { [ accumulate( [1, 2, 3], sub ($inp2) { $inp ~ $inp2 } )]}),
          [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']],
          'recursive';
is-deeply accumulate(['the', 'quick', 'brown', 'fox'], sub { @_[0].flip }),
          ['eht', 'kciuq', 'nworb', 'xof'],
          'reverse strings';

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.179 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.178 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.177 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.176 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.175 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.174 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.173 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.172 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.171 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.170 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.169 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.167 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.166 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.165 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.164 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.163 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.162 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.161 tracks/perl6/exercises/accumulate/accumulate.t
trackler-2.2.1.160 tracks/perl6/exercises/accumulate/accumulate.t