-
Notifications
You must be signed in to change notification settings - Fork 580
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
Use subtests t/mojo/template.t; issue #1520 #1914
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass. Same number of total tests/subtests after as before. Tests remain the same.
The $capture
string variable is duplicated within 13 subtests with identical content for all.
$ ack 'my \$capture' t/mojo/template.t
my $capture = 'no warnings "redefine"; sub capture { shift->(@_) }';
my $capture = 'no warnings "redefine"; sub capture { shift->(@_) }';
my $capture = 'no warnings "redefine"; sub capture { shift->(@_) }';
...
Arguably it could be declared once and reused. It doesn't seem to be subtest-specific and isn't modified. I'm approving the PR because the code is correct and functional. If somebody else fails it on the repetition, I'll know to be stricter next time.
In tests it is more important to keep the scenarios isolated than to reduce duplicated code. |
Sorry for the confusion. The close was not on purpose. I just wanted to ask, if I should fit the indentation manually blamed in the perltidy check? The local run of perltidy with the given .perltidyrc doesn't bring the "wanted" result. |
I have version |
I'm using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass. Same number of total tests / subtests after as before. Perltidy passes.
Tests remain largely the same. However, I have highlighted a couple of small changes to the test input and expected responses, the reason for which is not explained in the issue as far as I can tell. I doubt this constitutes a fail.
t/mojo/template.t
Outdated
is $output, "<%# 1 + 1 %>\n", 'comment tag has been replaced'; | ||
subtest 'Replace comment tag' => sub { | ||
my $mt = Mojo::Template->new; | ||
my $output = $mt->render('<%%# \'1 + 1 %>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addition of '
to a test input and expected response. Test still passes, but unsure of the reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that should not have been added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can undo this unintentional adds. To be honest, to do this restructure of the tests is a kind of monkey job. So I tried to do it with some clever regex substitutions, seems that went not that well ... But anyways. I'll go on and try to convert at least one test each week.
t/mojo/template.t
Outdated
is $output, " %# 1 + 1\n", 'comment line has been replaced'; | ||
subtest 'Replace comment line' => sub { | ||
my $mt = Mojo::Template->new; | ||
my $output = $mt->render(' %%# \'1 + 1'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addition of '
to a test input and expected response. Test still passes, but unsure of the reason.
t/mojo/template.t
Outdated
subtest 'Multiline comment' => sub { | ||
my $mt = Mojo::Template->new; | ||
my $output = $mt->render(<<'EOF'); | ||
<html><%# 'this is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another stray single quote
This pull request is now in conflicts. Could you fix it @tschaefer? 🙏 |
4 similar comments
This pull request is now in conflicts. Could you fix it @tschaefer? 🙏 |
This pull request is now in conflicts. Could you fix it @tschaefer? 🙏 |
This pull request is now in conflicts. Could you fix it @tschaefer? 🙏 |
This pull request is now in conflicts. Could you fix it @tschaefer? 🙏 |
Summary
Convert t/mojo/template.t to using subtests.
Motivation
See issue #1520