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.1.0.51 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.50 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.49 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.48 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.47 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.46 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.45 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.44 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.43 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.42 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.41 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.40 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.39 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.38 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.37 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.36 tracks/perl6/exercises/allergies/example.yaml
trackler-2.1.0.34 tracks/perl6/exercises/allergies/example.yaml