|
|
|
@ -65,3 +65,39 @@ test "World_progress_w_0" { |
|
|
|
|
try expect(p.x != 0); |
|
|
|
|
try expect(p.y != 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
test "World_progress_w_t" { |
|
|
|
|
var world = try World.init(std.testing.allocator); |
|
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
_ = world.component(Position); |
|
|
|
|
_ = world.component(Velocity); |
|
|
|
|
|
|
|
|
|
const e1 = world.entity(.{}, .{ Position, Velocity }); |
|
|
|
|
|
|
|
|
|
const move_system = world.system("move", move, c.EcsOnUpdate, "Position, Velocity"); |
|
|
|
|
|
|
|
|
|
var ctx = util.Probe.init(); |
|
|
|
|
c.ecs_set_context(world.raw, &ctx); |
|
|
|
|
|
|
|
|
|
_ = e1.set(Position, .{ .x = 0, .y = 0 }); |
|
|
|
|
_ = e1.set(Velocity, .{ .x = 1, .y = 2 }); |
|
|
|
|
|
|
|
|
|
_ = world.progress(2); |
|
|
|
|
|
|
|
|
|
try expectEql(ctx.count, 1); |
|
|
|
|
try expectEql(ctx.invoked, 1); |
|
|
|
|
try expectEql(ctx.system, move_system.raw); |
|
|
|
|
try expectEql(ctx.termCount, 2); |
|
|
|
|
try expectEql(ctx.param, null); |
|
|
|
|
|
|
|
|
|
try expectEql(ctx.e[0], e1.raw); |
|
|
|
|
try expectEql(ctx.c[0][0], (try world.lookupByType(Position)).raw); |
|
|
|
|
try expectEql(ctx.c[0][1], (try world.lookupByType(Velocity)).raw); |
|
|
|
|
try expectEql(ctx.s[0][0], 0); |
|
|
|
|
try expectEql(ctx.s[0][1], 0); |
|
|
|
|
|
|
|
|
|
const p = e1.get(Position).?; |
|
|
|
|
try expect(p.x == 2); |
|
|
|
|
try expect(p.y == 4); |
|
|
|
|
} |
|
|
|
|