const core = @import("core"); const std = @import("std"); const memory = core.MemoryTracker; const engine_log = core.engine_log; const engine_logs = core.engine_logs; test "simple systems setup for core" { std.testing.refAllDecls(core.algorithm); memory.MTSetup(std.testing.allocator, .{ .timeline = false }); defer memory.MTShutdown(); const tracker = memory.MTGet().?; const allocator = tracker.allocator(); std.debug.print("Starting up \n", .{}); engine_logs("systems starting"); try core.start_module(.{ .name = "test" }, .{ .unitTest = true }, allocator); defer core.shutdown_module(allocator); engine_logs("systems started, shutting down"); memory.MTPrintStatsDelta(); try test_loadingConfigs(); try test_consoleCommands(); try memory.dumpTimeline("test-core-timeline.txt"); } fn test_loadingConfigs() !void { if (core.getConfigVar(u32, "platform.extent.width")) |width| { core.engine_log("config: {d}", .{width}); } if (core.getConfigVar(u64, "platform.extent.height")) |height| { core.engine_log("config: {d}", .{height}); } if (core.getConfigVar(f32, "platform.extent.height")) |height| { core.engine_log("config f32: {d}", .{height}); } if (core.getConfigVar(f64, "platform.extent.height")) |height| { core.engine_log("config f64: {d}", .{height}); } if (core.getConfigVar([]const u8, "platform.windowName")) |height| { core.engine_log("config string: {s}", .{height}); } } fn test_consoleCommands() !void { const ConsoleCommands = struct { pub fn echo(args: []const u8) void { core.engine_log("{s}", .{args}); } pub fn foo(args: []const u8) void { core.engine_log("foo function called with args {s}", .{args}); } }; try core.console.addCommand("echo", ConsoleCommands.echo); try core.console.addCommand("foo", ConsoleCommands.foo); core.console.evaluate("echo lmfao"); core.console.evaluate("foo lmfao"); }