module Lapis::Test

Extended Modules

Defined in:

libgodot/testing.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.autofree_objects #

def self.autoqfree_nodes #

def self.tracked_nodes #

Instance Method Detail

def add_child_autofree(parent : Godot::Node, child : T) : T forall T #

Adds a child node to the parent and registers it for automatic queue_free


def add_child_autofree(child : T) : T forall T #

Overload when called in test_suite where single argument node is registered


def assert_alive(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that the Godot object is alive in ObjectDB and has not been destroyed


def assert_approx_eq(actual : Float32 | Float64, expected : Float32 | Float64, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that two floating-point values are approximately equal within a tolerance epsilon


def assert_between(actual : Number, min : Number, max : Number, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a numeric value falls within the inclusive range [min, max]


def assert_connected(emitter : Godot::Object, signal_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that emitter's signal has active connections


def assert_disposed(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that the Godot object has been destroyed/freed


def assert_emits(emitter : Godot::Object, signal_name : String, timeout_sec : Float64 = 2.0, file : String = __FILE__, line : Int32 = __LINE__, &) : Array(Variant) #

Executes the provided block and asserts that the specified signal is emitted within timeout_sec. Returns the emitted arguments. Raises AssertionError if the signal fails to emit.


def assert_empty(collection, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a collection is empty


def assert_eq(actual, expected, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that two values are equal using Crystal's == operator


def assert_false(cond : Bool, msg : String = "Expected false, got true", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that the boolean condition evaluates to false


def assert_file_does_not_exist(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a file does not exist on disk


def assert_file_empty(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a file is empty (0 bytes)


def assert_file_exists(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a file exists on disk


def assert_file_not_empty(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a file is not empty (> 0 bytes)


def assert_freed(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that an object has been freed / disposed (alias to assert_disposed)


def assert_gt(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that actual > expected


def assert_gte(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that actual >= expected


def assert_has_method(obj : Godot::Object, method_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a Godot object has a defined method


def assert_has_node(parent : Godot::Node, path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a Godot node has a child node at path


def assert_has_signal(emitter : Godot::Object, signal_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a Godot object has declared a signal


def assert_in_delta(actual : Number, expected : Number, delta : Number, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a numeric value is within delta of the expected value


def assert_includes(collection, item, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a collection contains the specified item


def assert_invalid_id(instance_id : UInt64 | Int64, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that an instance ID is no longer valid in Godot's ObjectDB


def assert_is_a(obj, klass : T.class, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) forall T #

Asserts that object is an instance of the given class


def assert_lt(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that actual < expected


def assert_lte(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that actual <= expected


def assert_ne(actual, expected, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that two values are not equal using Crystal's != operator


def assert_nil(val, msg : String = "Expected nil value", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a value is nil


def assert_no_emit(emitter : Godot::Object, signal_name : String, duration_sec : Float64 = 0.5, file : String = __FILE__, line : Int32 = __LINE__, &) : Void #

Executes the provided block and verifies that the specified signal is NOT emitted during duration_sec.


def assert_no_leak(max_delta_objects : Int32 = 0, name : String = "Operation", file : String = __FILE__, line : Int32 = __LINE__, &) #

Executes the provided block and asserts that Godot ObjectDB object and node counts return to baseline after Boehm GC collection and frame draining.


def assert_no_new_orphans(msg : String = "", file : String = __FILE__, line : Int32 = __LINE__, &) #

Asserts that the block does not introduce any orphan nodes (Performance::ObjectOrphanNodeCount)


def assert_not_between(actual : Number, min : Number, max : Number, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a numeric value does NOT fall within the inclusive range [min, max]


def assert_not_connected(emitter : Godot::Object, signal_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that emitter's signal has NO active connections


def assert_not_empty(collection, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a collection is not empty


def assert_not_freed(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that an object has NOT been freed / is alive (alias to assert_alive)


def assert_not_nil(val, msg : String = "Expected non-nil value", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a value is non-nil


def assert_not_same(actual : Reference, expected : Reference, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that actual and expected do not reference the exact same object


def assert_raises(klass : T.class, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__, &) forall T #

Asserts that evaluating the block raises an exception of the expected class T


def assert_refcount(refcounted : Godot::RefCounted, expected : Int32, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a RefCounted instance has the expected reference count


def assert_same(actual : Reference, expected : Reference, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that actual and expected reference the exact same object


def assert_signal_count(spy : SignalSpy, count : Int32, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a SignalSpy recorded exactly the expected number of emissions (backwards compatibility)


def assert_signal_emit_count(spy : SignalSpy, count : Int32, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a SignalSpy recorded exactly count emissions


def assert_signal_emitted(spy : SignalSpy, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a SignalSpy recorded at least one emission


def assert_signal_not_emitted(spy : SignalSpy, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that a SignalSpy did NOT record any emissions


def assert_string_contains(str : String, substr : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that string contains the specified substring


def assert_string_ends_with(str : String, suffix : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that string ends with the specified suffix


def assert_string_starts_with(str : String, prefix : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that string starts with the specified prefix


def assert_true(cond : Bool, msg : String = "Expected true, got false", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that the boolean condition evaluates to true


def assert_valid_id(instance_id : UInt64 | Int64, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that an instance ID is currently valid in Godot's ObjectDB


def assert_vector_approx(actual : Godot::Vector2, expected : Godot::Vector2, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that two Vector2 values are approximately equal within epsilon


def assert_vector_approx(actual : Godot::Vector3, expected : Godot::Vector3, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that two Vector3 values are approximately equal within epsilon


def assert_vector_approx(actual : Godot::Color, expected : Godot::Color, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) #

Asserts that two Color values are approximately equal within epsilon


def autofree(obj : T) : T forall T #

Registers an object to be safely disposed at the end of the test


def autofree_all : Void #

Alias for cleanup_autofree


def autoqfree(node : T) : T forall T #

Registers a node to be queue_freed at the end of the test


def await_signal(emitter : Godot::Object, signal_name : String, timeout_sec : Float64 = 2.0, file : String = __FILE__, line : Int32 = __LINE__) : Array(Variant) #

Cooperatively awaits a signal on the target emitter. If the signal is not received within timeout_sec, raises a descriptive TimeoutError. Returns the emitted arguments as an Array(Variant).


def cleanup_autofree : Void #

Cleans up all auto-freed objects and nodes created during a test


def cleanup_tracked_nodes : Void #

Cleans up all tracked nodes created during a test


def input_sender : InputSender #

def pending(reason : String = "Test pending implementation") : Nil #

Marks the currently running test as pending implementation


def simulate(node : Godot::Node, frames : Int32 = 1, delta : Float64 = 0.016666666666666666, physics : Bool = false) : Void #

Deterministically simulates frames of processing on a node and its recursive children


def skip_frames(count : Int32 = 1) : Void #

Cooperatively yields until the specified number of process (render/idle) frames have elapsed


def skip_if(condition : Bool, reason : String = "Test skipped") : Nil #

Conditionally skips the currently running test if condition evaluates to true


def skip_physics_frames(count : Int32 = 1) : Void #

Cooperatively yields until the specified number of fixed physics frames have elapsed


def suppress_errors(&) #

Temporarily suppresses engine error printing to stdout/stderr while evaluating the block


def track_node(node : Godot::Node) : Godot::Node #

Registers a node to be automatically destroyed and cleaned up in after_each


def with_node(klass : T.class, parent : Godot::Node | Nil = nil, &block : T -> Void) forall T #

Safely creates a node of type T, yields it to the block, and guarantees destruction


def with_timeout(timeout_sec : Float64 = 5.0, operation_name : String = "Operation", file : String = __FILE__, line : Int32 = __LINE__, &) #

Executes a block with an active timeout watchdog, raising TimeoutError if it fails to finish in time