Module talk:Yesno: Difference between revisions
→test failed: +one more failed test |
documentation is wrong |
||
| Line 98: | Line 98: | ||
::Thanks. Fixed. I moved your test case to the table above. --[[User:Ori.livneh|Ori.livneh]] ([[User talk:Ori.livneh|talk]]) 05:58, 3 March 2013 (UTC) | ::Thanks. Fixed. I moved your test case to the table above. --[[User:Ori.livneh|Ori.livneh]] ([[User talk:Ori.livneh|talk]]) 05:58, 3 March 2013 (UTC) | ||
:::Yesno has ~8M transclusions. No question it should handle the legacy 1:1. Test it. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 22:31, 11 March 2013 (UTC) | :::Yesno has ~8M transclusions. No question it should handle the legacy 1:1. Test it. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 22:31, 11 March 2013 (UTC) | ||
The documentation is wrong. The "egg" example assumes thet the input value is ''blank''. But in the code examples the input parameter is ''omitted''. Compare: | |||
* <nowiki>{{yesno|blank= eggs|no=ham}}</nowiki> → {{yesno|blank= eggs|no=ham}} | |||
* <nowiki>{{yesno||blank= eggs|no=ham}}</nowiki> → {{yesno||blank= eggs|no=ham}} | |||
This is what is actually documented: | |||
* <nowiki>{{yesno|blank= eggs|no=ham|¬=bread}}</nowiki> → {{yesno|blank= eggs|no=ham|¬=bread}} | |||
== Why? == | == Why? == | ||
Revision as of 13:11, 23 March 2013
| Module output | Template output | Expected |
|---|---|---|
| Script error: The module returned a function value. It is supposed to return an export table. | yes | yes |
| Script error: The module returned a function value. It is supposed to return an export table. | yes | yes |
| Script error: The module returned a function value. It is supposed to return an export table. | yes | yes |
| Script error: The module returned a function value. It is supposed to return an export table. | yes | yes |
| Script error: The module returned a function value. It is supposed to return an export table. | (blank) | |
| Script error: The module returned a function value. It is supposed to return an export table. | (blank) | |
| Script error: The module returned a function value. It is supposed to return an export table. | (blank) | |
| Script error: The module returned a function value. It is supposed to return an export table. | (blank) | |
| Script error: The module returned a function value. It is supposed to return an export table. | yes | yes |
| Script error: The module returned a function value. It is supposed to return an export table. | bacon | bacon |
| Script error: The module returned a function value. It is supposed to return an export table. | ham | ham |
| Script error: The module returned a function value. It is supposed to return an export table. | eggs | |
| Script error: The module returned a function value. It is supposed to return an export table. | ham | |
| Script error: The module returned a function value. It is supposed to return an export table. | eggs | |
| Script error: The module returned a function value. It is supposed to return an export table. | sausage | sausage |
| Script error: The module returned a function value. It is supposed to return an export table. | cup-of-tea | cup-of-tea |
| Script error: The module returned a function value. It is supposed to return an export table. | bacon | bacon |
| Script error: The module returned a function value. It is supposed to return an export table. | cup-of-tea | cup-of-tea |
| Script error: The module returned a function value. It is supposed to return an export table. | no | no |
| Script error: The module returned a function value. It is supposed to return an export table. | yes | yes |
| Script error: The module returned a function value. It is supposed to return an export table. | no | no |
As you can see, the template does not behave exactly as its documentation claims it does. I was not sure which to regard as authoritative: the ideal or actual implementation. I ultimately went with the former. Removing and not any from the Lua code will make the module behave like exactly like the template.
--Ori.livneh (talk) 10:46, 28 February 2013 (UTC)
- Just needs to handle spaces in the params better. -- WOSlinker (talk) 11:41, 2 March 2013 (UTC)
- Thanks. Fixed. I moved your test case to the table above. --Ori.livneh (talk) 05:58, 3 March 2013 (UTC)
The documentation is wrong. The "egg" example assumes thet the input value is blank. But in the code examples the input parameter is omitted. Compare:
- {{yesno|blank= eggs|no=ham}} →
- {{yesno||blank= eggs|no=ham}} → eggs
This is what is actually documented:
- {{yesno|blank= eggs|no=ham|¬=bread}} → bread
Why?
{{yesno}} is quite simple, so I'm not sure if there is a point in replacing it with functionally equivalent Lua. There are many cases where Lua can be much faster and easier to read, but I'm not sure that is the case here. In fact, because of the slight overhead with #invoke, simple parser functions can actually be slightly faster than the equivalent Lua. I haven't tested that here, but I wouldn't be surprised if there is no performance advantage in a case like this. Seems like a strange template to target for Lua conversion. Dragons flight (talk) 14:57, 12 March 2013 (UTC)
See also
- {{[[Module:{{{1}}}|#invoke:{{{1}}}]]|function}}
test failed
One fail found in unit test: value "1= ¬ " (with whitespace). Reason:whitespace not removed before this check. Possible solution; treat '¬' as a character, separate from nil. (if val == nil or val == '¬' then ...). -DePiep (talk) 11:54, 23 March 2013 (UTC)
- Another fail: input value="00". See Module talk:Yesno/testcases. -DePiep (talk) 12:56, 23 March 2013 (UTC)