fix(templateengine): SemanticValidator accepts composition-delegated CallScript (Children[x].CallScript leaf-name match)
This commit is contained in:
@@ -82,6 +82,49 @@ public class SemanticValidatorTests
|
||||
Assert.DoesNotContain(result.Errors, e => e.Category == ValidationCategory.CallTargetNotFound);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_CallScriptCompositionDelegatedByLeafName_NoError()
|
||||
{
|
||||
// A machine script delegating to a composed child's script via
|
||||
// Children["X"].CallScript("MoveIn") captures only the leaf "MoveIn";
|
||||
// the flattened script is the composed canonical "LeftMESReceiver.MoveIn".
|
||||
// The existence check must accept the leaf-name match (the child segment
|
||||
// is typically dynamic and cannot be statically resolved).
|
||||
var config = new FlattenedConfiguration
|
||||
{
|
||||
InstanceUniqueName = "Instance1",
|
||||
Scripts =
|
||||
[
|
||||
new ResolvedScript { CanonicalName = "LeftMESReceiver.MoveIn", Code = "var x = 1;" },
|
||||
new ResolvedScript { CanonicalName = "RightMESReceiver.MoveIn", Code = "var x = 1;" },
|
||||
new ResolvedScript { CanonicalName = "MesMoveIn", Code = "await Children[side + \"MESReceiver\"].CallScript(\"MoveIn\", Parameters);" }
|
||||
]
|
||||
};
|
||||
|
||||
var result = _sut.Validate(config);
|
||||
Assert.DoesNotContain(result.Errors, e => e.Category == ValidationCategory.CallTargetNotFound);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_CallScriptUnknownLeafName_StillReturnsError()
|
||||
{
|
||||
// Relaxation is leaf-name scoped: a target that matches neither a root
|
||||
// canonical name nor any composed leaf name is still flagged.
|
||||
var config = new FlattenedConfiguration
|
||||
{
|
||||
InstanceUniqueName = "Instance1",
|
||||
Scripts =
|
||||
[
|
||||
new ResolvedScript { CanonicalName = "LeftMESReceiver.MoveIn", Code = "var x = 1;" },
|
||||
new ResolvedScript { CanonicalName = "Caller", Code = "CallScript(\"Typo\");" }
|
||||
]
|
||||
};
|
||||
|
||||
var result = _sut.Validate(config);
|
||||
Assert.Contains(result.Errors, e =>
|
||||
e.Category == ValidationCategory.CallTargetNotFound && e.Message.Contains("Typo"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_CallSharedTargetNotFound_ReturnsError()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user