test.error catcher - Palamecia/mint GitHub Wiki

Module test.error-catcher

Description

load test.error-catcher

This module provides the Test.ErrorCatcher class which provides a context to manage runtime error conversion to exception.

Packages

Classes

Test.ErrorCatcher

This class provides a context to manage runtime error conversion to exception. All runtime errors reached with an instance of Test.ErrorCatcher active will automaticaly be converted into Test.RuntimeError and raised.

Test code can then catch the Test.RuntimeError to perform tests.

Example:

try {
    let catcher = Test.ErrorCatcher()
    1 % 0
} catch error {
    self.expectEquel('Test.RuntimeError', typeof error)
    self.expectEquel('modulo by zero', error.toString())
}

Public members

Modifiers Member Description
const new Creates a new context.

Private members

Modifiers Member Description
final d_ptr Internal context.
@ const g_lib Global library handle.

Test.RuntimeError

This class provides the context of a runtime error catched by an instance of Test.ErrorCatcher.

Inherits

Public members

Modifiers Member Description
const new Creates a new context. The message parameter provides the runtime error message.
const toString Returns the runtime error message.

Private members

Modifiers Member Description
final message Internal error mesage.

Descriptions

Test.ErrorCatcher.d_ptr

null

Internal context.

Test.ErrorCatcher.g_lib

lib ('libmint-test')

Global library handle.

Test.ErrorCatcher.new

def (self)

Creates a new context.

Test.RuntimeError.message

none

Internal error mesage.

Test.RuntimeError.new

def (self, message)

Creates a new context. The message parameter provides the runtime error message.

Test.RuntimeError.toString

def (const self)

Returns the runtime error message.