Top Level Namespace

Included Modules

Extended Modules

Defined in:

Method Summary

Macro Summary

Instance methods inherited from module Lapis::Test

add_child_autofree(parent : Godot::Node, child : T) : T forall T
add_child_autofree(child : T) : T forall T
add_child_autofree
, assert_alive(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_alive, assert_approx_eq(actual : Float32 | Float64, expected : Float32 | Float64, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_approx_eq, assert_between(actual : Number, min : Number, max : Number, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_between, assert_connected(emitter : Godot::Object, signal_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_connected, assert_disposed(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_disposed, assert_emits(emitter : Godot::Object, signal_name : String, timeout_sec : Float64 = 2.0, file : String = __FILE__, line : Int32 = __LINE__, &) : Array(Variant) assert_emits, assert_empty(collection, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_empty, assert_eq(actual, expected, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_eq, assert_false(cond : Bool, msg : String = "Expected false, got true", file : String = __FILE__, line : Int32 = __LINE__) assert_false, assert_file_does_not_exist(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_file_does_not_exist, assert_file_empty(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_file_empty, assert_file_exists(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_file_exists, assert_file_not_empty(path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_file_not_empty, assert_freed(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_freed, assert_gt(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_gt, assert_gte(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_gte, assert_has_method(obj : Godot::Object, method_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_has_method, assert_has_node(parent : Godot::Node, path : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_has_node, assert_has_signal(emitter : Godot::Object, signal_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_has_signal, assert_in_delta(actual : Number, expected : Number, delta : Number, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_in_delta, assert_includes(collection, item, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_includes, assert_invalid_id(instance_id : UInt64 | Int64, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_invalid_id, assert_is_a(obj, klass : T.class, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) forall T assert_is_a, assert_lt(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_lt, assert_lte(actual : Comparable, expected : Comparable, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_lte, assert_ne(actual, expected, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_ne, assert_nil(val, msg : String = "Expected nil value", file : String = __FILE__, line : Int32 = __LINE__) assert_nil, assert_no_emit(emitter : Godot::Object, signal_name : String, duration_sec : Float64 = 0.5, file : String = __FILE__, line : Int32 = __LINE__, &) : Void assert_no_emit, assert_no_leak(max_delta_objects : Int32 = 0, name : String = "Operation", file : String = __FILE__, line : Int32 = __LINE__, &) assert_no_leak, assert_no_new_orphans(msg : String = "", file : String = __FILE__, line : Int32 = __LINE__, &) assert_no_new_orphans, assert_not_between(actual : Number, min : Number, max : Number, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_not_between, assert_not_connected(emitter : Godot::Object, signal_name : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_not_connected, assert_not_empty(collection, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_not_empty, assert_not_freed(object : Godot::Object, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_not_freed, assert_not_nil(val, msg : String = "Expected non-nil value", file : String = __FILE__, line : Int32 = __LINE__) assert_not_nil, assert_not_same(actual : Reference, expected : Reference, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_not_same, assert_raises(klass : T.class, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__, &) forall T assert_raises, assert_refcount(refcounted : Godot::RefCounted, expected : Int32, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_refcount, assert_same(actual : Reference, expected : Reference, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_same, assert_signal_count(spy : SignalSpy, count : Int32, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_signal_count, assert_signal_emit_count(spy : SignalSpy, count : Int32, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_signal_emit_count, assert_signal_emitted(spy : SignalSpy, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_signal_emitted, assert_signal_not_emitted(spy : SignalSpy, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_signal_not_emitted, assert_string_contains(str : String, substr : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_string_contains, assert_string_ends_with(str : String, suffix : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_string_ends_with, assert_string_starts_with(str : String, prefix : String, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_string_starts_with, assert_true(cond : Bool, msg : String = "Expected true, got false", file : String = __FILE__, line : Int32 = __LINE__) assert_true, assert_valid_id(instance_id : UInt64 | Int64, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__) assert_valid_id, assert_vector_approx(actual : Godot::Vector2, expected : Godot::Vector2, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__)
assert_vector_approx(actual : Godot::Vector3, expected : Godot::Vector3, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__)
assert_vector_approx(actual : Godot::Color, expected : Godot::Color, epsilon : Float64 = 0.001, msg : String = "", file : String = __FILE__, line : Int32 = __LINE__)
assert_vector_approx
, autofree(obj : T) : T forall T autofree, autofree_all : Void autofree_all, autoqfree(node : T) : T forall T autoqfree, await_signal(emitter : Godot::Object, signal_name : String, timeout_sec : Float64 = 2.0, file : String = __FILE__, line : Int32 = __LINE__) : Array(Variant) await_signal, cleanup_autofree : Void cleanup_autofree, cleanup_tracked_nodes : Void cleanup_tracked_nodes, input_sender : InputSender input_sender, pending(reason : String = "Test pending implementation") : Nil pending, simulate(node : Godot::Node, frames : Int32 = 1, delta : Float64 = 0.016666666666666666, physics : Bool = false) : Void simulate, skip_frames(count : Int32 = 1) : Void skip_frames, skip_if(condition : Bool, reason : String = "Test skipped") : Nil skip_if, skip_physics_frames(count : Int32 = 1) : Void skip_physics_frames, suppress_errors(&) suppress_errors, track_node(node : Godot::Node) : Godot::Node track_node, with_node(klass : T.class, parent : Godot::Node | Nil = nil, &block : T -> Void) forall T with_node, with_timeout(timeout_sec : Float64 = 5.0, operation_name : String = "Operation", file : String = __FILE__, line : Int32 = __LINE__, &) with_timeout

Class methods inherited from module Lapis::Test

autofree_objects autofree_objects, autoqfree_nodes autoqfree_nodes, tracked_nodes tracked_nodes

Method Detail

def crystal_godot_init(api : Pointer(Godot::LibBridge::BridgeAPI)) : Void #

C ABI Entry point called by crystal_bridge when game library is loaded


def load(path : String, type_hint : String = "", cache_mode : Int64 = 0_i64) : Godot::Resource #

Global convenience helper to load resources from Godot VFS


def preload(path : String) : Godot::Resource #

Global convenience helper to preload resources from Godot VFS


def vec2(x : Number, y : Number) : Godot::Vector2 #

Top-level math constructors


def vec3(x : Number, y : Number, z : Number) : Godot::Vector3 #

def vec4(x : Number, y : Number, z : Number, w : Number) : Godot::Vector4 #

Macro Detail

macro abstract_class #

Convenience macro to designate a class as abstract in Godot.


macro await(target, signal_name = nil, timeout_sec = nil) #

Top-level await macro for intuitive GDScript-like calling syntax Usage: await(enemy.died) await(enemy.died, timeout_sec: 2.0) await(enemy, "died") await(enemy, "died", timeout_sec: 2.0) await(timer.timeout) await(timer) await(1.5) await(2.seconds)


macro await_until(condition, timeout_sec, &block) #

Cooperatively yields the current fiber until the condition evaluates to truthy. Usage: await_until(character.on_floor?) await_until(resource.loaded?, timeout_sec: 10.0)


macro await_while(condition, timeout_sec, &block) #

Cooperatively yields the current fiber while the condition evaluates to truthy. Usage: await_while(tween.is_running) await_while(character.moving?, timeout_sec: 5.0)


macro cold_boot_test(category, name, &block) #

Dedicated declarative cold boot test macro


macro define_log_filter(name, **opts) #

macro define_log_filters(&block) #

macro delegate_property_to_instance(*prop_names) #

Forwards class-level properties to the class singleton instance


macro delegate_to_instance(*method_names) #

Forwards class-level methods to the class singleton instance (e.g. Input, AudioServer)


macro emit(signal_expr, *args) #

Type-safe signal emitter macro.

Emits signals with compile-time type verification, matching the parameter types and argument counts declared by the signal.

Examples:

emit(player.health_changed, 50, 100) # Expands to player.emit_health_changed(50, 100)
emit(player.renamed)                  # Expands to player.emit_renamed
emit(health_changed, 50, 100)         # Inside Player: expands to emit_health_changed(50, 100)
emit(sig, 50, 100)                    # Signal variable: expands to sig.emit(50, 100)

macro ensure_lapis #

The primary node macro: Usage: node MyNode node MyNode do # defaults to Godot::Node end

node Player < CharacterBody3D node Player < CharacterBody3D do # inherits Godot::CharacterBody3D end Expressive loader macro to ensure Lapis engine bindings are loaded without duplicate require cycles or missing dependency errors


macro export_category(name, &block) #

Categories group top-level inspector sections in Godot.

May be used standalone or as a block scoping exported properties:

export_category "Combat" do
  @[Export]
  property health : Int32 = 100
end

macro export_group(name, prefix = "", &block) #

Groups exported properties in the Godot inspector.

May be used standalone or as a block scoping exported properties:

export_group "Movement", prefix: "move_" do
  @[Export]
  property move_speed : Float32 = 5.0_f32
end

macro export_subgroup(name, prefix = "", &block) #

Subgroups exported properties under the current inspector group.

May be used standalone or as a block scoping exported properties:

export_subgroup "Advanced", prefix: "adv_" do
  @[Export]
  property adv_friction : Float32 = 0.1_f32
end

macro gdclass(decl, &block) #

Declares a custom RefCounted or generic Godot engine class registered with ClassDB. Defaults to inheriting RefCounted when no parent is specified. Can be called with or without a block (e.g. gdclass MyState).

gdclass StateMachine < RefCounted do
  @[Export]
  property current_state : String = "idle"
end

gdclass SimpleState

macro gmodule(decl, &block) #

Declares a reusable Godot module or mixin registered with ClassDB metadata. Can declare properties (with @[Export]), signals, lifecycle hooks, and interface methods. When included into a node, gdclass, or resource via include, its properties and signals are automatically registered with ClassDB and dispatched via the GDExtension bridge.

Examples:

gmodule Damageable do
  signal health_changed(current : Int32, max : Int32)
  signal died

  @[Export(range: 0..100)]
  property health : Int32 = 100

  @[Export]
  property max_health : Int32 = 100

  def take_damage(amount : Int32) : Void
    self.health = Math.max(0, self.health - amount)
    emit(health_changed, self.health, self.max_health)
    emit(died) if self.health == 0
  end
end

node Player < CharacterBody2D do
  include Damageable
end

macro godot_bind(var_name, class_name, method_name, hash) #

Lazily retrieves and caches a GDExtension method bind handle from ClassDB


macro godot_call_str(method_name, *args) #

Dynamically calls an instance method and returns the result as a Crystal String


macro godot_collider_query(cls_name, indexed = false) #

Synthesizes null-safe #get_collider? query on raycasts and shapecasts


macro godot_marshal_enum(name, idx) #

Marshals an enum or integer argument into a typed 64-bit pointer for ptrcall


macro godot_marshal_nodepath(name, idx) #

Marshals a NodePath or String argument into an unmanaged Godot NodePath pointer


macro godot_marshal_obj(name, idx) #

Marshals a Godot Object wrapper into an unmanaged pointer-to-pointer for ptrcall


macro godot_marshal_str(name, idx) #

Marshals a String argument into an unmanaged Godot String pointer


macro godot_marshal_string_name(name, idx) #

Marshals a String or StringName argument into an interned StringName pointer


macro godot_marshal_val(name, idx) #

Marshals a primitive scalar (Float, Int, Bool, Vector2/3, Color) for ptrcall


macro godot_module(decl) #

macro godot_prop(prop_name, getter_name, setter_name = nil) #

Synthesizes an ergonomic getter and setter pair


macro godot_ptrcall(mb, target_ptr, args_slice, ret_ptr) #

Executes a low-overhead GDExtension ptrcall


macro godot_ptrcall_bool(mb, target_ptr, args_slice) #

Executes a ptrcall returning a boolean


macro godot_ptrcall_enum(mb, target_ptr, args_slice, enum_type) #

Executes a ptrcall returning a strongly-typed enum


macro godot_ptrcall_float(mb, target_ptr, args_slice) #

Executes a ptrcall returning a float (Float64 / Float32)


macro godot_ptrcall_float32(mb, target_ptr, args_slice) #

macro godot_ptrcall_float64(mb, target_ptr, args_slice) #

macro godot_ptrcall_int(mb, target_ptr, args_slice) #

Executes a ptrcall returning an integer (Int64)


macro godot_ptrcall_obj(mb, target_ptr, args_slice, class_type) #

Executes a ptrcall returning a typed object wrapper


macro godot_ptrcall_val(mb, target_ptr, args_slice, type_name) #

Executes a ptrcall returning a value type with default constructor (e.g. Vector2, Vector3, Color, Transform3D)


macro godot_ptrcall_void(mb, target_ptr, args_slice) #

Executes a void ptrcall with no return buffer


macro godot_return_enum(enum_type, ret_var) #

Instantiates a strongly-typed enum from a 64-bit ptrcall return buffer


macro godot_return_obj(class_type, ret_ptr) #

Wraps a returned native object pointer into its typed Crystal wrapper


macro godot_signal(name, *types) #

Synthesizes a first-class typed signal accessor and direct emission helper


macro godot_singleton(cls_name, godot_name, parent_type = Godot::Object) #

Defines a Godot singleton accessor and pointer caching


macro godot_singleton_accessor(method_name, cls_name) #

Emits top-level Godot module singleton helper


macro godot_static_call_str(method_name, *args) #

Dynamically calls a static engine method and returns the result as a Crystal String


macro group(*group_names) #

Declaratively assigns the node to one or more scene tree groups upon _ready.

node Player < CharacterBody3D do
  group "players", "flammable"
end

macro icon(path) #

Convenience macro to set a custom icon path in the editor.


macro log_filter(name, **opts) #

Re-export at top-level for maximum ergonomics


macro multiplayer_test(name, clients = 2, &block) #

Dedicated declarative multiplayer simulation test macro


macro n!(path, type = nil) #

Ultra-short aliases for node! and node?


macro n?(path, type = nil) #

macro node(decl, &block) #

macro node!(path, type = nil) #

Compact node retrieval macro (GDScript $ analog). Supports:

  1. Type-inferred: node!(Sprite2D) -> get_node_as("Sprite2D", Sprite2D)
  2. Path + Type: node!("Visuals/Sprite2D", Sprite2D) -> get_node_as("Visuals/Sprite2D", Sprite2D)
  3. Path string: node!("Visuals/Sprite2D") -> get_node("Visuals/Sprite2D")

macro node2d(decl, &block) #

Expressive convenience macro for 2D scene nodes defaulting to Godot::Node2D


macro node3d(decl, &block) #

Expressive convenience macro for 3D spatial nodes defaulting to Godot::Node3D


macro node?(path, type = nil) #

Safe compact node retrieval macro (returns nil if not found).


macro node_path!(path) #

Creates a compile-time verified Godot::NodePath


macro node_ref(decl) #

Declares a node_ref property initialized from the scene tree during _ready.


macro node_ref(name_or_decl, type = nil, path = nil) #

Declares a dead-pointer safe, lazy-cached node property matching Godot's @onready pattern.

Supports:

  1. Macro signature: node_ref player, Player, "Player"
  2. Type declaration: node_ref player : Player = "Player"
  3. Auto-inferred: node_ref sprite_2d : Sprite2D

macro onready(decl) #

Declares an @onready node property initialized from the scene tree during _ready.


macro onready(name, type, path = nil) #

Declares a lazy-cached node property matching Godot's @onready pattern.

Supports:

  1. Auto-inferred path: onready sprite_2d, Sprite2D (fetches "Sprite2D")
  2. Scene Unique Node: onready camera, Camera2D, "%MainCamera"
  3. Explicit path: onready sprite, Sprite2D, "Visuals/Sprite2D"

macro onready?(name, type, path = nil) #

Declares a safe, lazy-cached node property that returns nil if missing or type mismatch.

Examples:

onready? player, PlayerController, "Player"
onready? hud, GameHUD, "HUD"

macro resource(decl, &block) #

Declares a custom Godot Resource class registered with ClassDB and EditorHelp. Supports @[Export] properties, custom signals, and serialization to .tres.

resource ItemData < Resource do
  @[Export]
  property item_name : String = "Health Potion"

Declares a custom Resource subclass registered with ClassDB.
Defaults to inheriting `Resource` when no parent is specified.
Can be called with or without a block (e.g. `resource MyItem`).

resource CustomPotion do @[Export] property item_name : String = "Health Potion"

@[Export] property value : Int32 = 50 end

resource ShortItem


macro signal(name_or_decl, *extra_types) #

Declares a custom Godot signal and generates a type-safe emit_<signal_name> helper method.

class Player < Godot::CharacterBody3D
  signal health_changed(new_health : Int32, max_health : Int32)
  signal died

  def take_damage(amount : Int32)
    emit_health_changed(50, 100)
    emit_died if amount >= 100
  end
end

macro static_unload #

Convenience macro to mark extension library unloading behavior.


macro test_case(category, name, cold_boot = false, &block) #

Base test_case macro


macro test_suite(category, &block) #

Declarative suite macro allowing grouped tests, parameterized tests, and suite/case lifecycle hooks


macro u!(name, type = nil) #

Ultra-short aliases for unique! and unique?


macro u?(name, type = nil) #

macro unique!(name, type = nil) #

Compact Scene Unique Node retrieval macro (GDScript % analog). Supports:

  1. Type-inferred: unique!(ProgressBar) -> get_node_as("%ProgressBar", ProgressBar)
  2. Name + Type: unique!("HealthBar", ProgressBar) -> get_node_as("%HealthBar", ProgressBar)
  3. Name string: unique!("HealthBar") -> get_node("%HealthBar")

macro unique?(name, type = nil) #

Safe compact Scene Unique Node retrieval macro (returns nil if not found).


macro unique_node(name, type, unique_name = nil) #

Declares a lazy-cached Scene Unique Node property (Godot 4 %Node syntax).

Examples:

unique_node health_bar, ProgressBar      # fetches "%HealthBar"
unique_node main_hud, CanvasLayer, "HUD" # fetches "%HUD"

macro unique_node?(name, type, unique_name = nil) #

Declares a safe, lazy-cached Scene Unique Node property that returns nil if missing.

Examples:

unique_node? health_bar, ProgressBar, "HealthBar"

macro unique_node_ref(decl) #

Declares a unique_node_ref property initialized from the scene tree during _ready.


macro unique_node_ref(name_or_decl, type = nil, unique_name = nil) #

Declares a dead-pointer safe, lazy-cached Scene Unique Node property (Godot 4 %Node syntax).

Supports:

  1. Macro signature: unique_node_ref camera, Camera2D, "MainCamera"
  2. Type declaration: unique_node_ref camera : Camera2D = "MainCamera"
  3. Auto-inferred: unique_node_ref main_hud : CanvasLayer

macro warning_ignore(name) #

Convenience macro to suppress compiler warnings.


macro warning_ignore_restore(name) #

macro warning_ignore_start(name) #