Lutok: anonymous_namespace{state_test.cpp} Namespace Reference

Lutok 0.6.2

Loading...
Searching...
No Matches
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

## ◆ c_get_upvalues()

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_state | The raw Lua state.

Returns
  The number of result values, i.e. 2.

## ◆ check_modules()

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

  state | The Lua state.
  expected | The module to expect. Empty if no modules are allowed.

## ◆ cxx_divide()

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

  state | The Lua state.

Returns
  The number of result values, i.e. 1.

Exceptions

  std::runtime_error | If the divisor is zero.
  std::string | If 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.

## ◆ cxx_multiply_closure()

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

  state | The Lua state.

Returns
  The number of result values, i.e. 1.

## ◆ is_available()

static bool anonymous_namespace{state_test.cpp}::is_available | ( | lutok::state & | state,
|  | const char * | symbol
| ) |  |
| static

Checks if a symbol is available.

Parameters

  state | The Lua state.
  symbol | The symbol to check for.

Returns
  True if the symbol is defined, false otherwise.

## ◆ raise_long_error()

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

  state | The Lua state.

Returns
  Never returns.

Exceptions

  std::runtime_error | Unconditionally, with an error message formed by the repetition of 'A' as many times as requested.