Glimmer2 inline {{unless}}#13019
Glimmer2 inline {{unless}}#13019GavinJoyce wants to merge 1 commit intoemberjs:masterfrom GavinJoyce:gj/inline-unless
{{unless}}#13019Conversation
There was a problem hiding this comment.
We could write export function inlineIf(
|
@chancancode Do you think there is value in repeating all the existing inline if tests for inline unless? (I'm currently just testing the main use, outlined below) If so, any ideas on how I might avoid simply duplicating them? moduleFor('Helpers test: inline {{unless}}', class extends SharedHelperConditionalsTest {
templateFor({ cond, truthy, falsy }) {
return `{{unless ${cond} ${falsy} ${truthy}}}`;
}
}, BASIC_TRUTHY_TESTS, BASIC_FALSY_TESTS); |
|
@GavinJoyce yeah, I think we should test them. I think we mostly did the work to make them fairly reusable (by "duplicating" a few lines we get 20+ tests). I think there are a few kinds of scenarios:
|
|
@GavinJoyce in your specific example: moduleFor('Helpers test: inline {{unless}}', class extends SharedHelperConditionalsTest {
templateFor({ cond, truthy, falsy }) {
return `{{unless ${cond} ${falsy} ${truthy}}}`;
}
}, BASIC_TRUTHY_TESTS, BASIC_FALSY_TESTS);I think this level of duplication is acceptable. The main boilerplate here is the Besides that, I think all the code here are actually saying something meaningful. (I probably would prefer not having to do the |
|
Thanks, I'll spend some time tomorrow trying to make the tests as succinct as possible |
|
🤘 |
|
Of course, if only difference is just the string I am 50-50 on these kinds of DRY-ing refactor. IMO this makes things much harder to read/reason about and usually isn't worth it when the amount of duplication is not that high. I think when the factor is just 2 (if, unless), the repetition is cheaper than the extra cognitive overhead, but I will probably be happy with whatever you decided is better. |
|
☔ The latest upstream changes (presumably #13047) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
it would be nice to provide different asserting messages for {{if}} and {{unless}} but having a generic message now allows the tests to be compatible with HTMLBars. Perhaps I should add a TODO?
|
@chancancode this is ready for review. I didn't use I used your "without inverse" trick for |
{{unless}}{{unless}}
|
☔ The latest upstream changes (presumably #13087) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Rebased and merged in #13092, thanks @GavinJoyce! |
follow on from #12920
part of the Glimmer Big-Picture Integration Checklist
TODO: