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.8 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.7 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.6 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.5 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.4 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.3 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.2 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.1 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.1.0 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.6 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.5 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.4 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.3 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.2 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.1 tracks/perl6/exercises/allergies/example.yaml
trackler-2.2.0.0 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.55 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.54 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.53 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.52 tracks/perl6/exercises/allergies/example.yaml