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