Sha256: 7ab59a6730d5f69cb7eb27869eabfb44fe698ed52b05bbe6cdf6738e6eb4aeaf

Contents?: true

Size: 1.5 KB

Versions: 83

Compression:

Stored size: 1.5 KB

Contents

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

my Version:D $version = v3;

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

subtest "Roster class methods", {
  plan 3;
  ok ::('Roster').can($_), $_ for <add-student list-grade list-all>;
}

my $roster = ::('Roster').new;

ok $roster.?add-student(:name('Jim'), :2grade), 'Add Jim to grade 2';
cmp-ok $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';
cmp-ok $roster.?list-grade(2), '~~', <Jim Zoe>, 'List grade 2';
cmp-ok $roster.?list-grade(1), '~~', <Barb>, 'List grade 1';

cmp-ok $roster.?list-all, '~~', ('Grade 1', <Barb>, 'Grade 2', <Jim Zoe>), 'List all';

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>;

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

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.158 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.157 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.156 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.155 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.154 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.153 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.152 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.151 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.150 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.149 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.148 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.147 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.146 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.145 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.144 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.143 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.142 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.141 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.140 tracks/perl6/exercises/grade-school/grade-school.t