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.119 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.118 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.117 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.116 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.115 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.114 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.113 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.111 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.110 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.109 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.108 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.107 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.106 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.105 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.104 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.103 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.102 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.101 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.100 tracks/perl6/exercises/allergies/.meta/exercise-data.yaml
trackler-2.2.1.99 tracks/perl6/exercises/allergies/example.yaml