lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 26/04/2013, at 12:43 AM, Philipp Janda <siffiejoe@gmx.net> wrote:

>  return values are not that easy either

Handling return values at all seems pretty hard with a hook (anyone got any bright ideas?), so it's either a decorator as you use, or writing a tricky loader that parses doc comments and adds code, as Steve suggested at one stage.

>  [*]: Ahh, new idea: Unit testing using examples in the docstring ...

It's an idea I really like.  [1] does something similar: it looks for <pre> blocks in markdown files (i.e. lines with four spaces in front of them) and tries to execute them, checking that the results are the same as indicated by comments in the same style as in PiL.  It means that examples in the documentation are always correct.  At one stage I thought about doing the same thing for TeX (but then I didn't).

Cheers,
Geoff

[1] https://github.com/geoffleyland/rima/blob/master/lua/test/doctest.lua