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.139 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.138 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.137 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.136 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.135 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.134 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.133 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.132 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.131 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.130 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.129 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.128 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.127 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.126 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.125 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.124 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.123 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.122 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.121 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.120 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml