Regularized unit testing framework.

This commit is contained in:
2021-01-12 15:49:05 -05:00
parent 25b9b4cb5d
commit 6bf1476e5e
14 changed files with 174 additions and 167 deletions

View File

@@ -98,9 +98,22 @@
// So therefore, we have to provide a separate "safe" space for global data
// structures. That is provided elsewhere, in the module "globaldb".
//
//
// UNITTESTS
//
// We reserve the lua class name 'unittests' for storing unit tests. Any
// function placed into this class is considered a unit test. We don't
// separate unit tests from the rest of the code - they're compiled right
// into the main binary.
//
// Unit tests can be either lua functions, or Lua-registered C functions.
// Unit tests are executed by calling 'source_run_unittests'.
//
// Each unit test is run in a protected 'pcall' environment. Any errors
// are printed out to console. (At least for now).
//
////////////////////////////////////////////////////////////
#ifndef SOURCE_HPP
#define SOURCE_HPP
@@ -138,9 +151,19 @@ int source_update(lua_State *L);
//
// Rebuild the lua environment: clear it out, then reinstall all the
// functions that should be there. See above for more information.
// If an error exists in any of the source files, or when loading any
// of the closures, the error is (currently) printed. We'll come up
// with better error handling later.
//
int source_rebuild(lua_State *L);
// source_run_unittests
//
// Run all the unit tests. Print any errors to console. Pushes zero
// onto the lua stack if there are no errors, or one if there are.
//
int source_run_unittests(lua_State *L);
#endif // SOURCE_HPP