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