Sha256: b03be5a995b38885bdf82d34791d480b0baaeb0d3acd31be558d95bba8dbbdd3

Contents?: true

Size: 1.44 KB

Versions: 96

Compression:

Stored size: 1.44 KB

Contents

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

my $exercise = 'GradeSchool';
my $version = v1;
my $module = %*ENV<EXERCISM> ?? 'Example' !! $exercise;
plan 10;

use-ok $module or bail-out;
require ::($module);

if ::($exercise).^ver !~~ $version {
  warn "\nExercise version mismatch. Further tests may fail!"
    ~ "\n$exercise is $(::($exercise).^ver.gist). "
    ~ "Test is $($version.gist).\n";
  bail-out 'Example version must match test version.' if %*ENV<EXERCISM>;
}

require ::($module) <Roster>;

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

done-testing;

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.2.1.43 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.42 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.41 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.40 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.39 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.38 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.37 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.36 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.35 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.34 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.33 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.32 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.31 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.30 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.29 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.28 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.27 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.26 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.25 tracks/perl6/exercises/grade-school/grade-school.t
trackler-2.2.1.24 tracks/perl6/exercises/grade-school/grade-school.t