Sha256: 52b17339dece2db54a09e2da2e85e97807be057f06607bbaa10dfb663ca724d7

Contents?: true

Size: 1.18 KB

Versions: 83

Compression:

Stored size: 1.18 KB

Contents

exercise: Allergies
version: 4
plan: 2
tests: |-
  for $c-data<cases>.values -> %case-set {

    subtest 'allergic-to' => {
      plan 7;
      for %case-set<cases>.values -> %case {
        for %case<expected>.values {
          given allergic-to %case<input><score>, .<substance> -> $result {
            subtest %case<description> ~ ': ' ~ .<substance> => {
              plan 2;
              isa-ok $result, Bool;
              is-deeply $result, .<result>, 'Result matches expected';
            }
          }
        }
      }
    } when %case-set<description> ~~ 'allergicTo';

    subtest 'list-allergies' => {
      plan 9;
      for %case-set<cases>.values {
        cmp-ok list-allergies(.<input><score>), '~~', .<expected>.Set, .<description>;
      }
    } when %case-set<description> ~~ 'list';

  }

unit: module
example: |-
  our @allergens = <
      eggs
      peanuts
      shellfish
      strawberries
      tomatoes
      chocolate
      pollen
      cats
  >;

  sub allergic-to($code,$substance) is export {
      return so $code +& ( 2 ** @allergens.first({ $_ eq $substance},:k) )
  }

  sub list-allergies($code) is export {
      return grep { allergic-to($code,$_) }, @allergens;
  }

Version data entries

83 entries across 83 versions & 1 rubygems

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