Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 1.62 KB

development.md

File metadata and controls

26 lines (16 loc) · 1.62 KB

Development

How lua-error is put together and tested.

Where the Code Lives

Only dmc_lua/lua_error.lua is written in this repository. dmc_lua/lua_class.lua is a copy from lua-class, kept so the module and its tests work from a plain clone. Fix it there, then copy it here by hand.

DMC-Lua-Library copies lua_error.lua into its dmc_lua/ with its Snakemake build (the Snakefile here registers the module and its requirement, lua-class), and every DMC Solar2D library copies it from there into dmc_corona/lib/dmc_lua/. dmc-error is the Solar2D front end for it. Other DMC libraries use it for their own errors: lua-bytearray, lua-files, dmc-websockets, dmc-wamp, dmc-autostore.

Testing

The tests are in spec/ and use busted under Lua 5.1 (luarocks install busted). From the repository's root folder:

busted spec
++++++++++++++++++++++++++++++++
32 successes / 0 failures / 0 errors / 0 pending : 0.006165 seconds

spec/lua_error_spec.lua creates Error objects and a subclass, and checks their fields and __tostring__(). spec/try_spec.lua tests try, catch and finally: every combination of the parts, the return values, errors going on up, and where an error's traceback starts. spec/no_global_spec.lua checks that the module loads with lua-class's global newClass turned off.

busted has a finally() of its own in a spec's environment, so try_spec.lua takes the module's try, catch and finally from _G.