|
|
@ -31,9 +31,9 @@ test "Entity_init_id_name" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("foo", "{}", .{path}); |
|
|
|
try expect.fmt("foo", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -46,9 +46,9 @@ test "Entity_init_id_path" { |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -90,7 +90,7 @@ test "Entity_init_id_w_scope" { |
|
|
|
const scope = try world.entity(.{}, .{}); |
|
|
|
const scope = try world.entity(.{}, .{}); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{}, .{}); |
|
|
|
const e = try world.entity(.{}, .{}); |
|
|
|
|
|
|
|
|
|
|
@ -103,17 +103,17 @@ test "Entity_init_id_name_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
|
|
|
|
|
|
|
|
try expect.true(e.has(.{ c.EcsChildOf, scope })); |
|
|
|
try expect.true(e.has(.{ c.EcsChildOf, scope })); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -124,18 +124,18 @@ test "Entity_init_id_path_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
|
|
|
|
|
|
|
|
try expect.equal("grandchild", e.getName()); |
|
|
|
try expect.equal("grandchild", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -146,18 +146,18 @@ test "Entity_init_id_fullpath_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const p = try Path.fromString("::parent.child.grandchild", .{ .root_sep = "::", .sep = "." }, flecs.allocator); |
|
|
|
const p = try Path.fromString("::parent.child.grandchild", .{ .root_sep = "::", .sep = "." }, flecs.allocator); |
|
|
|
defer p.deinit(); |
|
|
|
defer p.deinit(); |
|
|
|
const e = try world.entity(.{ .path = p }, .{}); |
|
|
|
const e = try world.entity(.{ .path = p }, .{}); |
|
|
|
|
|
|
|
|
|
|
|
try expect.equal("grandchild", e.getName()); |
|
|
|
try expect.equal("grandchild", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -168,10 +168,10 @@ test "Entity_init_id_fullpath_w_scope_existing" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const p = try Path.fromString("::parent.child.grandchild", .{ .root_sep = "::", .sep = "." }, flecs.allocator); |
|
|
|
const p = try Path.fromString("::parent.child.grandchild", .{ .root_sep = "::", .sep = "." }, flecs.allocator); |
|
|
|
defer p.deinit(); |
|
|
|
defer p.deinit(); |
|
|
@ -180,9 +180,9 @@ test "Entity_init_id_fullpath_w_scope_existing" { |
|
|
|
const r = try world.entity(.{ .path = p }, .{}); |
|
|
|
const r = try world.entity(.{ .path = p }, .{}); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
|
|
|
|
|
|
|
|
|
try expect.equal("grandchild", e.getName()); |
|
|
|
try expect.equal("grandchild", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -198,9 +198,9 @@ test "Entity_init_id_name_1_comp" { |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{TagA}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{TagA}); |
|
|
|
try expect.true(e.has(TagA)); |
|
|
|
try expect.true(e.has(TagA)); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("foo", "{}", .{path}); |
|
|
|
try expect.fmt("foo", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -218,9 +218,9 @@ test "Entity_init_id_name_2_comp" { |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{ TagA, TagB }); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{ TagA, TagB }); |
|
|
|
try expect.true(e.has(TagA)); |
|
|
|
try expect.true(e.has(TagA)); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("foo", "{}", .{path}); |
|
|
|
try expect.fmt("foo", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -237,16 +237,16 @@ test "Entity_init_id_name_2_comp_w_scope" { |
|
|
|
_ = try world.tag(TagB); |
|
|
|
_ = try world.tag(TagB); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "child" }, .{ TagA, TagB }); |
|
|
|
const e = try world.entity(.{ .name = "child" }, .{ TagA, TagB }); |
|
|
|
try expect.true(e.has(TagA)); |
|
|
|
try expect.true(e.has(TagA)); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -292,9 +292,9 @@ test "Entity_init_id_path_w_sep" { |
|
|
|
const p = try Path.fromString("parent::child", .{ .root_sep = null, .sep = "::" }, flecs.allocator); |
|
|
|
const p = try Path.fromString("parent::child", .{ .root_sep = null, .sep = "::" }, flecs.allocator); |
|
|
|
defer p.deinit(); |
|
|
|
defer p.deinit(); |
|
|
|
const e = try world.entity(.{ .path = p }, .{}); |
|
|
|
const e = try world.entity(.{ .path = p }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
@ -305,7 +305,7 @@ test "Entity_find_id_name" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
@ -320,7 +320,7 @@ test "Entity_find_w_existing_id_name" { |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .id = id, .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .id = id, .name = "foo" }, .{}); |
|
|
|
try expect.equal(e, id); |
|
|
|
try expect.equal(e, id); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
@ -332,15 +332,15 @@ test "Entity_find_id_name_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
|
|
|
|
|
|
|
@ -356,9 +356,9 @@ test "Entity_find_id_path" { |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
|
|
|
|
|
|
|
@ -372,17 +372,17 @@ test "Entity_find_id_path_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("grandchild", e.getName()); |
|
|
|
try expect.equal("grandchild", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child.grandchild", "{}", .{path}); |
|
|
|
|
|
|
|
|
|
|
@ -396,7 +396,7 @@ test "Entity_find_id_name_match" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r = try world.entity(.{ .id = e, .name = "foo" }, .{}); |
|
|
|
const r = try world.entity(.{ .id = e, .name = "foo" }, .{}); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
@ -408,15 +408,15 @@ test "Entity_find_id_name_match_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try e.getPath(flecs.allocator); |
|
|
|
const path = try e.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
try expect.fmt("parent.child", "{}", .{path}); |
|
|
|
|
|
|
|
|
|
|
@ -439,7 +439,7 @@ test "Entity_find_id_path_match" { |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r = try world.entity(.{ .id = e, .path = e_path }, .{}); |
|
|
|
const r = try world.entity(.{ .id = e, .path = e_path }, .{}); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
@ -451,15 +451,15 @@ test "Entity_find_id_path_match_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("grandchild", e.getName()); |
|
|
|
try expect.equal("grandchild", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r1 = try world.entity(.{ .id = e, .path = e_path }, .{}); |
|
|
|
const r1 = try world.entity(.{ .id = e, .path = e_path }, .{}); |
|
|
|
try expect.equal(e, r1); |
|
|
|
try expect.equal(e, r1); |
|
|
@ -478,7 +478,7 @@ test "Entity_find_id_name_mismatch" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = try world.entity(.{ .name = "bar" }, .{}); |
|
|
|
_ = try world.entity(.{ .name = "bar" }, .{}); |
|
|
|
|
|
|
|
|
|
|
@ -495,13 +495,13 @@ test "Entity_find_id_name_mismatch_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "child" }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const prev_log_level = c.ecs_log_set_level(-4); |
|
|
|
const prev_log_level = c.ecs_log_set_level(-4); |
|
|
|
defer _ = c.ecs_log_set_level(prev_log_level); |
|
|
|
defer _ = c.ecs_log_set_level(prev_log_level); |
|
|
@ -518,7 +518,7 @@ test "Entity_find_id_path_mismatch" { |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_parts = Path.buildParts(.{ "parent", "child" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("child", e.getName()); |
|
|
|
try expect.equal("child", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const prev_log_level = c.ecs_log_set_level(-4); |
|
|
|
const prev_log_level = c.ecs_log_set_level(-4); |
|
|
|
defer _ = c.ecs_log_set_level(prev_log_level); |
|
|
|
defer _ = c.ecs_log_set_level(prev_log_level); |
|
|
@ -535,15 +535,15 @@ test "Entity_find_id_path_mismatch_w_scope" { |
|
|
|
defer world.deinit(); |
|
|
|
defer world.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
const scope = try world.entity(.{ .name = "parent" }, .{}); |
|
|
|
try expect.equal("parent", scope.getName()); |
|
|
|
try expect.equal("parent", scope.name()); |
|
|
|
|
|
|
|
|
|
|
|
_ = world.setScope(scope); |
|
|
|
_ = world.setScope(scope); |
|
|
|
try expect.equal(scope, world.getScope()); |
|
|
|
try expect.equal(scope, world.scope()); |
|
|
|
|
|
|
|
|
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_parts = Path.buildParts(.{ "child", "grandchild" }); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e_path = Path.fromParts(false, &e_parts); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
const e = try world.entity(.{ .path = e_path }, .{}); |
|
|
|
try expect.equal("grandchild", e.getName()); |
|
|
|
try expect.equal("grandchild", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const unnamed_parts = Path.buildParts(.{ "child", "foo" }); |
|
|
|
const unnamed_parts = Path.buildParts(.{ "child", "foo" }); |
|
|
|
const unnamed_path = Path.fromParts(false, &unnamed_parts); |
|
|
|
const unnamed_path = Path.fromParts(false, &unnamed_parts); |
|
|
@ -566,7 +566,7 @@ test "Entity_find_id_add_1_comp" { |
|
|
|
_ = try world.tag(TagA); |
|
|
|
_ = try world.tag(TagA); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{TagA}); |
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{TagA}); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
@ -585,7 +585,7 @@ test "Entity_find_id_add_2_comp" { |
|
|
|
_ = try world.tag(TagB); |
|
|
|
_ = try world.tag(TagB); |
|
|
|
|
|
|
|
|
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const e = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", e.getName()); |
|
|
|
try expect.equal("foo", e.name()); |
|
|
|
|
|
|
|
|
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{ TagA, TagB }); |
|
|
|
const r = try world.entity(.{ .name = "foo" }, .{ TagA, TagB }); |
|
|
|
try expect.equal(e, r); |
|
|
|
try expect.equal(e, r); |
|
|
@ -607,9 +607,9 @@ test "Entity_init_w_scope_name" { |
|
|
|
_ = world.setScope(foo); |
|
|
|
_ = world.setScope(foo); |
|
|
|
|
|
|
|
|
|
|
|
const child = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
const child = try world.entity(.{ .name = "foo" }, .{}); |
|
|
|
try expect.equal("foo", child.getName()); |
|
|
|
try expect.equal("foo", child.name()); |
|
|
|
|
|
|
|
|
|
|
|
const path = try child.getPath(flecs.allocator); |
|
|
|
const path = try child.path(flecs.allocator); |
|
|
|
defer path.deinit(); |
|
|
|
defer path.deinit(); |
|
|
|
try expect.fmt("parent.foo.foo", "{}", .{path}); |
|
|
|
try expect.fmt("parent.foo.foo", "{}", .{path}); |
|
|
|
} |
|
|
|
} |
|
|
|