public void TerminateLifetimeWithUnboundedInputLifetimeWired_ValidateVariableUsages_LifetimeCannotBeTerminatedErrorMessageReported() { DfirRoot function = DfirRoot.Create(); TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(function.BlockDiagram, 1, 1); ConnectConstantToInputTerminal(terminateLifetime.InputTerminals[0], PFTypes.Int32, false); RunSemanticAnalysisUpToValidation(function); Assert.IsTrue(terminateLifetime.GetDfirMessages().Any(message => message.Descriptor == Messages.TerminateLifetimeInputLifetimeCannotBeTerminated.Descriptor)); }
public void TerminateLifetimeWithStructureBorderInputLifetimeWired_ValidateVariableUsages_LifetimeCannotBeTerminatedErrorMessageReported() { DfirRoot function = DfirRoot.Create(); Frame frame = Frame.Create(function.BlockDiagram); BorrowTunnel borrowTunnel = CreateBorrowTunnel(frame, BorrowMode.Immutable); ConnectConstantToInputTerminal(borrowTunnel.InputTerminals[0], PFTypes.Int32, false); TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(frame.Diagram, 1, 1); Wire wire = Wire.Create(frame.Diagram, borrowTunnel.OutputTerminals[0], terminateLifetime.InputTerminals[0]); RunSemanticAnalysisUpToValidation(function); Assert.IsTrue(terminateLifetime.GetDfirMessages().Any(message => message.Descriptor == Messages.TerminateLifetimeInputLifetimeCannotBeTerminated.Descriptor)); }
public void TerminateLifetimeWithAllVariablesInLifetimeWired_ValidateVariableUsages_NoError() { DfirRoot function = DfirRoot.Create(); TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(function.BlockDiagram, 2, 1); ExplicitBorrowNode borrow = ConnectExplicitBorrowToInputTerminals(terminateLifetime.InputTerminals[0], terminateLifetime.InputTerminals[1]); ConnectConstantToInputTerminal(borrow.InputTerminals[0], PFTypes.Int32, false); ConnectConstantToInputTerminal(borrow.InputTerminals[1], PFTypes.Int32, false); RunSemanticAnalysisUpToValidation(function); Assert.AreEqual(TerminateLifetimeErrorState.NoError, terminateLifetime.ErrorState); Assert.IsFalse(terminateLifetime.GetDfirMessages().Any()); }
public void TerminateLifetimeWithInputLifetimeThatOutlastsDiagramWired_ValidateVariableUsages_LifetimeCannotBeTerminatedErrorMessageReported() { DfirRoot function = DfirRoot.Create(); Frame frame = Frame.Create(function.BlockDiagram); Tunnel tunnel = CreateInputTunnel(frame); ExplicitBorrowNode borrow = ConnectExplicitBorrowToInputTerminals(tunnel.InputTerminals[0]); ConnectConstantToInputTerminal(borrow.InputTerminals[0], PFTypes.Int32, false); TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(frame.Diagram, 1, 1); Wire wire = Wire.Create(frame.Diagram, tunnel.OutputTerminals[0], terminateLifetime.InputTerminals[0]); RunSemanticAnalysisUpToValidation(function); Assert.IsTrue(terminateLifetime.GetDfirMessages().Any(message => message.Descriptor == Messages.TerminateLifetimeInputLifetimeCannotBeTerminated.Descriptor)); }
public void TerminateLifetimeWithMultipleInputLifetimesWired_ValidateVariableUsages_NonUniqueLifetimeErrorMessageReported() { DfirRoot function = DfirRoot.Create(); TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(function.BlockDiagram, 2, 1); ExplicitBorrowNode borrow1 = ConnectExplicitBorrowToInputTerminals(terminateLifetime.InputTerminals[0]); ConnectConstantToInputTerminal(borrow1.InputTerminals[0], PFTypes.Int32, false); ExplicitBorrowNode borrow2 = ConnectExplicitBorrowToInputTerminals(terminateLifetime.InputTerminals[1]); ConnectConstantToInputTerminal(borrow2.InputTerminals[0], PFTypes.Int32, false); RunSemanticAnalysisUpToValidation(function); Assert.IsTrue(terminateLifetime.GetDfirMessages().Any(message => message.Descriptor == Messages.TerminateLifetimeInputLifetimesNotUnique.Descriptor)); }
public void TerminateLifetimeWithNotAllVariablesInLifetimeWired_ValidateVariableUsages_NotAllVariablesInLifetimeConnectedErrorMessageReported() { DfirRoot function = DfirRoot.Create(); TerminateLifetimeNode terminateLifetime = new TerminateLifetimeNode(function.BlockDiagram, 1, 1); ExplicitBorrowNode borrow = ConnectExplicitBorrowToInputTerminals(terminateLifetime.InputTerminals[0]); ConnectConstantToInputTerminal(borrow.InputTerminals[0], PFTypes.Int32, false); FunctionalNode passthrough = new FunctionalNode(function.BlockDiagram, Signatures.ImmutablePassthroughType); borrow.OutputTerminals[0].WireTogether(passthrough.InputTerminals[0], SourceModelIdSource.NoSourceModelId); RunSemanticAnalysisUpToValidation(function); Assert.IsTrue(terminateLifetime.GetDfirMessages().Any(message => message.Descriptor == Messages.TerminateLifetimeNotAllVariablesInLifetimeConnected.Descriptor)); }