Sha256: 12ea221f78743d1193e273430777b53066b34c881fa688ce7aa4105c44b02f85

Contents?: true

Size: 1007 Bytes

Versions: 77

Compression:

Stored size: 1007 Bytes

Contents

exercise: Allergies
version: 1
plan: 4
imports: '&allergic-to &list-allergies'
tests: |
  for @($c-data<cases>) -> %cases {
    subtest 'allergic-to' => {
      plan 7;
      my @cases = |%cases<cases>;
      for @cases -> %case {
        is allergic-to(%case<score>, .<substance>), .<result>, %case<description> for @(%case<expected>);
      }
    } if %cases<description> ~~ 'allergicTo';
    subtest 'list-allergies' => {
      plan 9;
      my @cases = |%cases<cases>;
      for @cases {
        is list-allergies(.<score>), |.<expected description>;
      }
    } if %cases<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

77 entries across 77 versions & 1 rubygems

Version Path
trackler-2.2.1.48 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.47 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.46 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.45 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.44 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.43 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.42 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.41 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.40 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.39 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.38 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.37 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.36 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.35 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.34 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.33 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.32 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.31 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.30 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.29 tracks/perl6/exercises/allergies/example.yaml