Content deleted Content added
No edit summary |
m Replaced deprecated <source> tags with <syntaxhighlight> (via WP:JWB) |
||
(15 intermediate revisions by 7 users not shown) | |||
Line 13:
:That sounded like a good idea to me, and it will be useful for [[Module:Documentation]] which I'm working on now, so I went ahead and added an [[Module:ScribuntoUnit#assertContains|assertContains]] method. Take a look and let me know if you have any suggestions for how it could be improved. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 16:32, 2 January 2014 (UTC)
:: It looks great, thank you :) Do you have a page where you check the assertions work correctly and that their diagnostic messages look good? I did not find [[Module:ScribuntoUnit/testcases]]. --[[User:Derbeth|Derbeth]] [[User talk:Derbeth|<sup>talk</sup>]] 20:01, 2 January 2014 (UTC)
::: Great. But perhaps we should name it <code>assertStringContains</code> in case we later implement a method that checks if a table contains a given table key? And yes, we should have tests for the assertions as well. I'm not really sure how to write good tests for a testing module, but I started experimenting on [[Module:ScribuntoUnit/testcases]]. – ''[[User:Danmichaelo|Danmichaelo]] ([[User talk:Danmichaelo|talk]])'' 08:42, 3 January 2014 (UTC)
:::: So renamed. Sounds like a good reason to me. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 14:05, 3 January 2014 (UTC)
::: Automated tests are needed, but I think there is also a need for a visual presentation of how the module works in practise. I have created such a page: [[Module:ScribuntoUnit/showcase]] (run on the talk page). If I did not invoke something wrong, it seems that {{mono|assertWithinDelta}} ignores the custom message. Plus, test methods are run in no particular order - can we do something about it? --[[User:Derbeth|Derbeth]] [[User talk:Derbeth|<sup>talk</sup>]] 21:08, 3 January 2014 (UTC)
:::: Agree, the showcase page is a good idea. Seems like the output is not so consistent between the different methods; on failure, some methods include "actual" and "expected", while others do not. If "actual" and "expected" are included, "message" is not shown. This leads me to thinking that we might be better of just replacing the two columns by a single column. I updated [[Module:ScribuntoUnit/sandbox]] and [[Module talk:ScribuntoUnit/showcase]]. What do you think? – ''[[User:Danmichaelo|Danmichaelo]] ([[User talk:Danmichaelo|talk]])'' 18:21, 5 January 2014 (UTC)
::: I made small tweaks to the sandbox code. I like it now. --[[User:Derbeth|Derbeth]] [[User talk:Derbeth|<sup>talk</sup>]] 10:31, 6 January 2014 (UTC)
== AssertWithinDelta ==
The docs for <s>assertDeltaContains</s> assertWithinDelta says " While 1/3 == 9/3 evaluates as false, ...". This is an obvious result, as they are completely different numbers. I assume this was a typo for "1/3 == 3/9 evaluates as false"; however, when I tried this in the debug console just now it evaluated as true. Is there a better example we can use to demonstrate floating point error here? Personally, I haven't seen it action in Scribunto yet, so I can't think of a good one. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 14:02, 3 January 2014 (UTC)
: True, that was a completely wrong example :) I've added a new one, and tested it in the debug console. Btw., the reason I added the method was that I ran into the problem on [[:no:Module:Coordinate/testtilfeller]]. – ''[[User:Danmichaelo|Danmichaelo]] ([[User talk:Danmichaelo|talk]])'' 00:45, 5 January 2014 (UTC)
:: Thanks for clearing that up. :) It's interesting to see how the floating point error works in a real-world example. I've given the docs a copy edit and expanded them a little to note that integers can be represented exactly up to 2^53. Feel free to tweak that if you want. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 11:48, 5 January 2014 (UTC)
== Table display ==
At the moment, if two different tables are tested for equality, the wikitable generated by the module simply lists them both as "table". It would be nice to actually show the contents of the table in a reasonably nice format. Perhaps we can do something with [[Module:User:Anomie/deepToString]] and/or [https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FScribunto.git/dbbf1803c6489dcb58d77566044e283ec17e7602/engines%2FLuaCommon%2Flualib%2Fmw.lua#L575 mw.logObject]? deepToString fails when trying to display mw.title objects, and while mw.logObject handles them ok, it only outputs to the log buffer. So we would need to do some tweaking to get something that suits our purposes, but it probably wouldn't be too hard. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 12:00, 5 January 2014 (UTC)
: Hm, how does it fail? I tried using mw.title at [[Module_talk:ScribuntoUnit/showcase]], and it seems to work, but I'm not familiar with it. – ''[[User:Danmichaelo|Danmichaelo]] ([[User talk:Danmichaelo|talk]])'' 18:47, 5 January 2014 (UTC)
:: You used the mw.title library, rather than a title object. To get a title object you need to use code like <code>mw.title.new('Wikipedia:Sandbox')</code>. I tried doing just that in the showcase module, and the whole script fails with a "not enough memory" error. The problem is that some of the title object fields are self-references. For example:
<syntaxhighlight lang="lua">
local sandbox = mw.title.new('Wikipedia:Sandbox') -- title object for [[Wikipedia:Sandbox]]
sandbox.basePageTitle -- Also the title object for [[Wikipedia:Sandbox]]
sandbox.basePageTitle.basePageTitle -- Again, the same title object.
</syntaxhighlight>
:: So if you try and iterate recursively through any given title object, while respecting metatables, you will just keep on going forever. Scribunto then dies when it runs into the memory limit. This problem has been resolved somehow in mw.logObject, but I haven't looked deeply enough at the code to know exactly what was done. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 11:06, 6 January 2014 (UTC)
== Failure category, config module ==
{{ping|Luis150902}} thanks for your recent module config changes. A while ago I adapted this module to be used at the English Wiktionary. One thing I found lacking was a category the test page automatically gets assigned to upon failure. Maybe this could now be added as a configurable setting? I would also suggest to move the configuration into <code>Module:ScribuntoUnit/configuration</code> or similar, so that the module can be copied as is. – [[User:Jberkel|Jberkel]] ([[User talk:Jberkel|talk]]) 05:22, 26 February 2018 (UTC)
:{{ping|Jberkel}} {{done}} [[User:Luis150902|<span style="color:#f00;">Luis150902</span>]] ([[User talk:Luis150902|<span style="color:#990;">talk</span>]] | [[Special:Contributions/Luis150902|<span style="color:#008000;">contribs</span>]]) 18:35, 26 February 2018 (UTC)
== Internationalizing this module ==
Hi, would anyone be interested in collaborating on making this module multilingual using [[Module:TNT]]? With this approach, we will get these benefits:
* identical code on all wikis, using global translation table
* no need for config submodule - can store than in the translation table too
* Once in sync, keeping it in sync will be easier with [[mw:WP:TNT|multilingual distribution system]].
--[[User:Yurik|Yurik]] ([[User talk:Yurik|talk]]) 22:25, 5 May 2019 (UTC)
|