New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test.pm6 make subtest multi to take description first #5237
Comments
From @zoffixznetHey, 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. Here's an example of the current way to use subtest: subtest { my $expected My proposal, if implemented, would allove the above to be written as: subtest '.list method' => { my $expected 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? |
From @moritzHi, On 04/13/2016 02:52 PM, Zoffix Znet (via RT) wrote:
Why not simply allow two ordinary arguments? Like this: Since one of the arguments is always a string or String-alike (probably All in all I approve of this idea though. Cheers, |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetOn Wed Apr 13 06:36:41 2016, moritz wrote:
Sure, that works too. Maybe it's just my Perl 5 mind, but the version with `=>` kinda says "this description is FOR THIS code." Maybe it's just me.
Alright. I'll submit code and tests. This will need to be deferred until 6.d, won't it? If we release and document this right now, modules using the new subtest version might not work, depending on which 6.c compiler version the user is using. |
From @zoffixznetPR for this feature: rakudo/rakudo#743 |
From @zoffixznetThe PR implementing this has been merged in rakudo/rakudo@e239f6e Closing. |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#127890 (status was 'resolved')
Searchable as RT127890$
The text was updated successfully, but these errors were encountered: