tracks/perl6/exercises/flatten-array/flatten-array.t in trackler-2.2.1.43 vs tracks/perl6/exercises/flatten-array/flatten-array.t in trackler-2.2.1.44

- old
+ new

@@ -2,14 +2,16 @@ use v6; use Test; use lib my $dir = $?FILE.IO.dirname; use JSON::Fast; -my $exercise = 'FlattenArray'; -my $version = v1; -my $module = %*ENV<EXERCISM> ?? 'Example' !! $exercise; -plan 8; +my Str:D $exercise := 'FlattenArray'; +my Version:D $version = v1; +my Str $module //= $exercise; +INIT { + plan 8; +} use-ok $module or bail-out; require ::($module); if ::($exercise).^ver !~~ $version { @@ -20,18 +22,12 @@ } require ::($module) <&flatten-array>; my $c-data; -is-deeply &::('flatten-array')(.<input>), |.<expected description> for @($c-data<cases>); +is-deeply flatten-array(.<input>), |.<expected description> for @($c-data<cases>); -if %*ENV<EXERCISM> { - if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f { - is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data'; - } else { flunk 'canonical-data' } -} else { skip } - done-testing; INIT { $c-data := from-json q:to/END/; @@ -77,6 +73,22 @@ } ] } END + + if %*ENV<EXERCISM> { + $module = 'Example'; + if (my $c-data-file = + "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json" + .IO.resolve) ~~ :f + { + is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data'; + } + else { + flunk 'canonical-data'; + } + } + else { + skip; + } }