@@ -3844,3 +3844,65 @@ void Template_template_w_nested_template_w_with_kind_value(void) {
38443844
38453845 ecs_fini (world );
38463846}
3847+
3848+ void Template_pair_component_w_entity_prop_target (void ) {
3849+ ecs_world_t * world = ecs_init ();
3850+
3851+ ECS_COMPONENT (world , Position );
3852+
3853+ ecs_struct (world , {
3854+ .entity = ecs_id (Position ),
3855+ .members = {
3856+ {"x" , ecs_id (ecs_f32_t )},
3857+ {"y" , ecs_id (ecs_f32_t )}
3858+ }
3859+ });
3860+
3861+ const char * expr =
3862+ LINE "template Foo {\n"
3863+ LINE " prop tgt = flecs.meta.entity: flecs\n"
3864+ LINE " (Position, $tgt): {5, 6}\n"
3865+ LINE "}\n"
3866+ LINE "ent { Foo: {flecs.core} }\n"
3867+ LINE "\n" ;
3868+
3869+ test_assert (ecs_script_run (world , NULL , expr , NULL ) == 0 );
3870+
3871+ ecs_entity_t foo = ecs_lookup (world , "Foo" );
3872+ ecs_entity_t ent = ecs_lookup (world , "ent" );
3873+
3874+ test_assert (foo != 0 );
3875+ test_assert (ent != 0 );
3876+
3877+ test_assert (ecs_has_id (world , ent , foo ));
3878+ test_assert (ecs_has_pair (world , ent , ecs_id (Position ), EcsFlecsCore ));
3879+
3880+ const Position * p = ecs_get_pair (world , ent , Position , EcsFlecsCore );
3881+ test_assert (p != NULL );
3882+ test_int (p -> x , 5 );
3883+ test_int (p -> y , 6 );
3884+
3885+ ecs_fini (world );
3886+ }
3887+
3888+ void Template_child_name_from_string_prop (void ) {
3889+ ecs_world_t * world = ecs_init ();
3890+
3891+ const char * expr =
3892+ LINE "template Foo {"
3893+ LINE " prop suffix = flecs.meta.string: \"a\""
3894+ LINE " \"child_$suffix\" {}"
3895+ LINE "}"
3896+ LINE "ent { Foo: {suffix: \"hello\"} }"
3897+ LINE "" ;
3898+
3899+ test_assert (ecs_script_run (world , NULL , expr , NULL ) == 0 );
3900+
3901+ ecs_entity_t ent = ecs_lookup (world , "ent" );
3902+ test_assert (ent != 0 );
3903+
3904+ ecs_entity_t child = ecs_lookup (world , "ent.child_hello" );
3905+ test_assert (child != 0 );
3906+
3907+ ecs_fini (world );
3908+ }
0 commit comments