Jump to content

User:SMcCandlish/sandbox if test

From Wikipedia, the free encyclopedia

Self-testing template

[edit]

This tests exactly how

  1. {{{1|}}}{{{2|}}} and
  2. {{{1|{{{2|}}}}}}

are distinct in the first half of an #if: test.


Test cases

[edit]


{{User:SMcCandlish/sandbox if test|1=|2=bar}}
{{{1|}}}{{{2|}}} version:
{{{1|{{{2|}}}}}} version:
default

☒N Inconsistent output: Specifying the parameter as an explicit null (rather than the entire parameter not being present) will not allow the null to be overwritten by the second, otherwise equivalent parameter in the first version. This applies no matter how it it is set to null (see next several examples). This has implications for infoboxes, etc., since they are often given with empty but named parameters to fill in later. Someone using an alias of the parameter name might not replace such a placeholder but simply add the alias (e.g. |place_of_death= is present and someone adds |place of death=Botswana or |place-of-death=Botswana).

Whether this is a bug or a feature is a matter of interpretation. If coded the first way, it forces someone to resolve the parameter conflict to get the template to display the intended information, which is a good thing. On the other hand, not all editors will understand this and may just think the template is broken (if they even notice the error). The reason the feature exists is so that, e.g. {{foo}}, {{foo|1=something}}, and {{foo|1=}} can all produce different output (with the first case producing default output, the second something specific, and the third suppressing whatever the feature is). This has proven to be confusing to most users, and most templates are no longer coded to do this (since the mid-2000s). Please do not create more that do.



{{User:SMcCandlish/sandbox if test||bar}}
{{{1|}}}{{{2|}}} version:
{{{1|{{{2|}}}}}} version:
default

See previous note.



{{User:SMcCandlish/sandbox if test||2=bar}}
{{{1|}}}{{{2|}}} version:
{{{1|{{{2|}}}}}} version:
default

See previous note.



{{User:SMcCandlish/sandbox if test|2=bar|1=}}
{{{1|}}}{{{2|}}} version:
{{{1|{{{2|}}}}}} version:
default

See previous note.



{{User:SMcCandlish/sandbox if test|2=bar|}}
{{{1|}}}{{{2|}}} version:
{{{1|{{{2|}}}}}} version:
default

See previous note.



{{User:SMcCandlish/sandbox if test|foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo

checkY This, and all other cases below, work exactly as expected: The two versions produce identical (and reasonable) output.



{{User:SMcCandlish/sandbox if test|1=foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|foo|bar}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|1=foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|1=foo|2=bar}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|2=bar}}
{{{1|}}}{{{2|}}} version:
bar
{{{1|{{{2|}}}}}} version:
bar


{{User:SMcCandlish/sandbox if test|2=bar|1=foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo



{{User:SMcCandlish/sandbox if test|2=bar|foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo



{{User:SMcCandlish/sandbox if test|foo|2=bar}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|foo|2=}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|1=foo|2=}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo



{{User:SMcCandlish/sandbox if test|foo|}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test}}
{{{1|}}}{{{2|}}} version:
default
{{{1|{{{2|}}}}}} version:
default


{{User:SMcCandlish/sandbox if test|2=|1=foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|2=|foo}}
{{{1|}}}{{{2|}}} version:
foo
{{{1|{{{2|}}}}}} version:
foo


{{User:SMcCandlish/sandbox if test|2=|1=}}
{{{1|}}}{{{2|}}} version:
default
{{{1|{{{2|}}}}}} version:
default


{{User:SMcCandlish/sandbox if test|2=|}}
{{{1|}}}{{{2|}}} version:
default
{{{1|{{{2|}}}}}} version:
default


{{User:SMcCandlish/sandbox if test|1=}}
{{{1|}}}{{{2|}}} version:
default
{{{1|{{{2|}}}}}} version:
default



{{User:SMcCandlish/sandbox if test||}}
{{{1|}}}{{{2|}}} version:
default
{{{1|{{{2|}}}}}} version:
default