Sha256: feeb4cfdd48ecce45ff33edf83c5999b30431caf603261cfd75c3fb19882c621

Contents?: true

Size: 1.11 KB

Versions: 51

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env perl6
use v6;
use Test;
use lib IO::Path.new($?FILE).parent.path;

plan 10;
my $module = %*ENV<EXERCISM> ?? 'Example' !! 'GradeSchool';
use-ok $module;
require ::($module) <Roster>;

subtest 'Can use all methods', {
  plan 3;
  ok Roster.can($_), $_ for <add-student list-grade list-all>;
} or fail 'Missing method(s)';

my $roster = Roster.new;

ok $roster.add-student(:name('Jim'), :2grade), 'Add Jim to grade 2';
is $roster.list-grade(2), <Jim>, 'List grade 2';
ok $roster.add-student(:name('Zoe'), :2grade), 'Add Zoe to grade 2';
ok $roster.add-student(:name('Barb'), :1grade), 'Add Barb to grade 1';
is $roster.list-grade(2), <Jim Zoe>, 'List grade 2';
is $roster.list-grade(1), <Barb>, 'List grade 1';

subtest 'Additional students', {
  plan 6;
  ok $roster.add-student(:name($_), :1grade), "Add $_ to grade 1" for <Charlie Anna>;
  ok $roster.add-student(:name('Alex'), :2grade), 'Add Alex to grade 2';
  ok $roster.add-student(:name($_), :3grade), "Add $_ to grade 3" for <Tom Dick Harry>;
}

is $roster.list-all, ('Grade 1', <Anna Barb Charlie>, 'Grade 2', <Alex Jim Zoe>, 'Grade 3', <Dick Harry Tom>), 'List all';

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
trackler-2.0.8.20 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.19 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.18 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.17 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.16 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.15 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.14 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.13 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.12 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.11 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.10 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.9 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.8 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.7 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.6 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.5 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.4 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.3 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.2 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.0.8.1 tracks/perl6/exercises/grade-school/grade-school.t