# New Ticket Created by Zoffix Znet # Please include the string: [perl #127890] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=127890 >
Hey, I propose we make Test.pm6's `subtest` a multi sub that can also take a Pair. The key of the Pair is to be the description of the test and the value is to be the codeblock to run. Test.pm6 has `subtest` sub that lets you group your tests. It takes a code block and description, but that description follows AFTER the codeblock, following the same pattern as all the other subs the module provides. The problem is unlike all the other subs, `subtest` takes a codeblock, which can get large quickly. A programmer reading the code has to skip through all the way to the END of the codeblock to find the description and understand what the subtest is testing. Here's an example of the current way to use subtest: subtest { my $res= $glot.list; ok $res.keys ⊆ <next content last>, 'return keys match expectations'; my $expected = <created files_hash id language modified owner public title url>; for |$res<content> { ok .keys ⊆ $expected, 'item keys match expectations'; } }, '.list method'; My proposal, if implemented, would allove the above to be written as: subtest '.list method' => { my $res= $glot.list; ok $res.keys ⊆ <next content last>, 'return keys match expectations'; my $expected = <created files_hash id language modified owner public title url>; for |$res<content> { ok .keys ⊆ $expected, 'item keys match expectations'; } }; It's immediately clear that the subtest is for the .list method, without any need to skim to the end. Also, this mirrors how the most common testing module in Perl 5 offers the `subtest` sub (https://metacpan.org/pod/Test::More#subtest). If the proposal is approved, I'm happy to write the code and tests. The one issue I'm wondering about is versioning. Were the feature implemented today, modules that use the new `subtest` multi for tests won't work on, say, 2016.01 Perl 6. How would we resolve that?