#!/usr/bin/env perl6 use Test; use JSON::Tiny; use lib ( my $dir = IO::Path.new($?FILE).parent ).path; my $module_name = %*ENV.so ?? 'Example' !! 'Allergies'; my @potential_module = .map: $module_name ~ '.' ~ *; my $module = first { $dir.child($_).e }, |@potential_module or die "No file '$module_name.p6' found\n"; require $module <&allergic-to &list-allergies>; plan 2; my %cases = from-json $dir.child('cases.json').slurp; subtest 'allergic-to' => { my @cases = |%cases{'allergic_to'}{'cases'}; plan +@cases; for |@cases -> %case { subtest %case. => { plan +|%case.; for |%case. -> %expected { is allergic-to(%case.,%expected.), %expected. or diag %expected; } } } }; subtest 'list' => { my @cases = |%cases{'list'}{'cases'}; plan +@cases; for |@cases { is list-allergies(.), ., . or diag $_; } };