Lutok  0.4
 All Classes Namespaces Files Functions Variables Macros
Functions
anonymous_namespace{state_test.cpp} Namespace Reference

Functions

static bool is_available (lutok::state &state, const char *symbol)
 Checks if a symbol is available.
static void check_modules (lutok::state &state, const std::string &expected)
 Checks that no modules are present or that only one has been loaded.
static int c_get_upvalues (lua_State *raw_state)
 A C closure that returns its two integral upvalues.
static int cxx_multiply_closure (lutok::state &state)
 A custom C++ multiply function with one of its factors on its closure.
static int cxx_divide (lutok::state &state)
 A custom C++ integral division function for Lua.
static int raise_long_error (lutok::state &state)
 A Lua function that raises a very long error message.

Function Documentation

static int anonymous_namespace{state_test.cpp}::c_get_upvalues ( lua_State *  raw_state)
static

A C closure that returns its two integral upvalues.

Postcondition:
stack(-2) contains the first upvalue.
stack(-1) contains the second upvalue.
Parameters:
raw_stateThe raw Lua state.
Returns:
The number of result values, i.e. 2.
static void anonymous_namespace{state_test.cpp}::check_modules ( lutok::state state,
const std::string &  expected 
)
static

Checks that no modules are present or that only one has been loaded.

Postcondition:
The test case terminates if there is any module present when expected is empty or if there two modules loaded when expected is defined.
Parameters:
stateThe Lua state.
expectedThe module to expect. Empty if no modules are allowed.
static int anonymous_namespace{state_test.cpp}::cxx_divide ( lutok::state state)
static

A custom C++ integral division function for Lua.

Precondition:
stack(-2) contains the dividend.
stack(-1) contains the divisor.
Postcondition:
stack(-2) contains the quotient of the division.
stack(-1) contains the remainder of the division.
Parameters:
stateThe Lua state.
Returns:
The number of result values, i.e. 1.
Exceptions:
std::runtime_errorIf the divisor is zero.
std::stringIf the dividend or the divisor are negative. This is an exception not derived from std::exception on purpose to ensure that the C++ wrapping correctly captures any exception regardless of its type.
static int anonymous_namespace{state_test.cpp}::cxx_multiply_closure ( lutok::state state)
static

A custom C++ multiply function with one of its factors on its closure.

Precondition:
stack(-1) contains the second factor.
Postcondition:
stack(-1) contains the product of the two input factors.
Parameters:
stateThe Lua state.
Returns:
The number of result values, i.e. 1.
static bool anonymous_namespace{state_test.cpp}::is_available ( lutok::state state,
const char *  symbol 
)
static

Checks if a symbol is available.

Parameters:
stateThe Lua state.
symbolThe symbol to check for.
Returns:
True if the symbol is defined, false otherwise.
static int anonymous_namespace{state_test.cpp}::raise_long_error ( lutok::state state)
static

A Lua function that raises a very long error message.

Precondition:
stack(-1) contains the length of the message to construct.
Parameters:
stateThe Lua state.
Returns:
Never returns.
Exceptions:
std::runtime_errorUnconditionally, with an error message formed by the repetition of 'A' as many times as requested.