예제 #1
0
        public void UnwrapOptionTunnelWithNoneInputAndDroppableUnwrapOptionTunnel_Execute_DroppableValueIsDropped()
        {
            DfirRoot       function = DfirRoot.Create();
            FunctionalNode some     = CreateInt32SomeConstructor(function.BlockDiagram, 0);
            var            none     = new FunctionalNode(function.BlockDiagram, Signatures.NoneConstructorType);
            var            assign   = new FunctionalNode(function.BlockDiagram, Signatures.AssignType);

            Wire.Create(function.BlockDiagram, some.OutputTerminals[0], assign.InputTerminals[0])
            .SetWireBeginsMutableVariable(true);
            Wire.Create(function.BlockDiagram, none.OutputTerminals[0], assign.InputTerminals[1]);
            Frame frame = Frame.Create(function.BlockDiagram);
            var   unwrapOptionTunnel = new UnwrapOptionTunnel(frame);

            Wire.Create(function.BlockDiagram, assign.OutputTerminals[0], unwrapOptionTunnel.InputTerminals[0]);
            FunctionalNode createFakeDrop = CreateFakeDropWithId(function.BlockDiagram, 1);
            var            someFakeDrop   = new FunctionalNode(function.BlockDiagram, Signatures.SomeConstructorType);

            Wire.Create(function.BlockDiagram, createFakeDrop.OutputTerminals[0], someFakeDrop.InputTerminals[0]);
            var someUnwrapOptionTunnel = new UnwrapOptionTunnel(frame);

            Wire.Create(function.BlockDiagram, someFakeDrop.OutputTerminals[0], someUnwrapOptionTunnel.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.DroppedFakeDropIds.Contains(1), "Expected FakeDrop value to be dropped.");
        }
예제 #2
0
        protected void TestPrimitiveOperation(
            NIType operationSignature,
            object leftValue,
            object rightValue,
            NIType inputType,
            bool mutating,
            Action <byte[]> testExpectedValue)
        {
            DfirRoot       function          = DfirRoot.Create();
            FunctionalNode functionNode      = new FunctionalNode(function.BlockDiagram, operationSignature);
            Constant       leftValueConstant = ConnectConstantToInputTerminal(functionNode.InputTerminals[0], inputType, leftValue, mutating);
            int            lastIndex         = 2;

            if (rightValue != null)
            {
                Constant rightValueConstant = ConnectConstantToInputTerminal(functionNode.InputTerminals[1], inputType, rightValue, false);
            }
            else
            {
                lastIndex = 1;
            }
            FunctionalNode inspect = ConnectInspectToOutputTerminal(mutating
                ? functionNode.OutputTerminals[0]
                : functionNode.OutputTerminals[lastIndex]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            testExpectedValue(inspectValue);
        }
예제 #3
0
        internal TestExecutionInstance CompileAndExecuteFunction(DfirRoot function, params DfirRoot[] otherFunctions)
        {
            var testExecutionInstance = new TestExecutionInstance();

            testExecutionInstance.CompileAndExecuteFunction(this, function, otherFunctions);
            return(testExecutionInstance);
        }
        public void BranchedStringSliceWire_Execute_BothSinksHaveCorrectValues()
        {
            DfirRoot           function            = DfirRoot.Create();
            Constant           stringSliceConstant = Constant.Create(function.BlockDiagram, "test", DataTypes.StringSliceType.CreateImmutableReference());
            var                inspect1Node        = new FunctionalNode(function.BlockDiagram, Signatures.InspectType);
            ExplicitBorrowNode borrow1             = ConnectExplicitBorrowToInputTerminals(inspect1Node.InputTerminals[0]);
            var                inspect2Node        = new FunctionalNode(function.BlockDiagram, Signatures.InspectType);
            ExplicitBorrowNode borrow2             = ConnectExplicitBorrowToInputTerminals(inspect2Node.InputTerminals[0]);

            Wire.Create(function.BlockDiagram, stringSliceConstant.OutputTerminal, borrow1.InputTerminals[0], borrow2.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

#if LLVM_TEST
            const int stringSliceReferenceSize = 16;
#else
            const int stringSliceReferenceSize = 8;
#endif

            byte[] inspect1Value = executionInstance.GetLastValueFromInspectNode(inspect1Node);
            Assert.AreEqual(stringSliceReferenceSize, inspect1Value.Length);
            byte[] inspect2Value = executionInstance.GetLastValueFromInspectNode(inspect2Node);
            Assert.AreEqual(stringSliceReferenceSize, inspect2Value.Length);
            Assert.IsTrue(inspect1Value.Zip(inspect2Value, (a, b) => a == b).All(b => b));
        }
예제 #5
0
        public void SumItemsFromRangeIterator_Execute_CorrectFinalResult()
        {
            DfirRoot            function        = DfirRoot.Create();
            Loop                loop            = new Loop(function.BlockDiagram);
            LoopConditionTunnel conditionTunnel = CreateLoopConditionTunnel(loop);
            IterateTunnel       iterateTunnel   = CreateIterateTunnel(loop);
            FunctionalNode      range           = new FunctionalNode(function.BlockDiagram, Signatures.RangeType);
            Wire                rangeWire       = Wire.Create(function.BlockDiagram, range.OutputTerminals[0], iterateTunnel.InputTerminals[0]);

            rangeWire.SetWireBeginsMutableVariable(true);
            Constant       lowConstant        = ConnectConstantToInputTerminal(range.InputTerminals[0], NITypes.Int32, 0, false);
            Constant       highConstant       = ConnectConstantToInputTerminal(range.InputTerminals[1], NITypes.Int32, 10, false);
            BorrowTunnel   borrow             = CreateBorrowTunnel(loop, BorrowMode.Mutable);
            Constant       accumulateConstant = ConnectConstantToInputTerminal(borrow.InputTerminals[0], NITypes.Int32, 0, true);
            FunctionalNode accumulateAdd      = new FunctionalNode(loop.Diagram, Signatures.DefineMutatingBinaryFunction("AccumulateAdd", NITypes.Int32));

            Wire.Create(loop.Diagram, borrow.OutputTerminals[0], accumulateAdd.InputTerminals[0]);
            Wire.Create(loop.Diagram, iterateTunnel.OutputTerminals[0], accumulateAdd.InputTerminals[1]);
            FunctionalNode inspect = ConnectInspectToOutputTerminal(borrow.TerminateLifetimeTunnel.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            AssertByteArrayIsInt32(inspectValue, 45);
        }
예제 #6
0
        internal TestExecutionInstance CompileAndExecuteFunction(DfirRoot function)
        {
            var testExecutionInstance = new TestExecutionInstance();

            testExecutionInstance.CompileAndExecuteFunction(this, function);
            return(testExecutionInstance);
        }
예제 #7
0
        public void UnwrapOptionTunnelWithSomeInputAndYieldingFrameInterior_Execute_FrameExecutes()
        {
            DfirRoot       function = DfirRoot.Create();
            FunctionalNode some     = new FunctionalNode(function.BlockDiagram, Signatures.SomeConstructorType);

            ConnectConstantToInputTerminal(some.InputTerminals[0], NITypes.Int32, 5, false);
            Frame frame = Frame.Create(function.BlockDiagram);
            UnwrapOptionTunnel unwrapOptionTunnel = new UnwrapOptionTunnel(frame);

            Wire.Create(function.BlockDiagram, some.OutputTerminals[0], unwrapOptionTunnel.InputTerminals[0]);
            BorrowTunnel borrowTunnel = CreateBorrowTunnel(frame, BorrowMode.Mutable);

            ConnectConstantToInputTerminal(borrowTunnel.InputTerminals[0], NITypes.Int32, 0, true);
            FunctionalNode assign    = new FunctionalNode(frame.Diagram, Signatures.AssignType);
            var            yieldNode = new FunctionalNode(frame.Diagram, Signatures.YieldType);

            Wire.Create(frame.Diagram, borrowTunnel.OutputTerminals[0], yieldNode.InputTerminals[0]);
            Wire.Create(frame.Diagram, yieldNode.OutputTerminals[0], assign.InputTerminals[0]);
            Wire.Create(frame.Diagram, unwrapOptionTunnel.OutputTerminals[0], assign.InputTerminals[1]);
            FunctionalNode inspect = ConnectInspectToOutputTerminal(borrowTunnel.TerminateLifetimeTunnel.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] finalValue = executionInstance.GetLastValueFromInspectNode(inspect);
            AssertByteArrayIsInt32(finalValue, 5);
        }
예제 #8
0
        public void InitializeVectorAndSumWithSliceIterator_Execute_CorrectSumValue()
        {
            DfirRoot       function         = DfirRoot.Create();
            FunctionalNode initializeVector = CreateInitializeVectorWithIntegerConstants(function.BlockDiagram, 4, 4);
            FunctionalNode vectorToSlice    = new FunctionalNode(function.BlockDiagram, Signatures.VectorToSliceType);

            Wire.Create(function.BlockDiagram, initializeVector.OutputTerminals[0], vectorToSlice.InputTerminals[0]);
            FunctionalNode sliceToIterator = new FunctionalNode(function.BlockDiagram, Signatures.SliceToIteratorType);

            Wire.Create(function.BlockDiagram, vectorToSlice.OutputTerminals[0], sliceToIterator.InputTerminals[0]);
            Loop loop = new Loop(function.BlockDiagram);

            CreateLoopConditionTunnel(loop);
            IterateTunnel iterateTunnel = CreateIterateTunnel(loop);
            BorrowTunnel  borrowTunnel  = CreateBorrowTunnel(loop, BorrowMode.Mutable);

            ConnectConstantToInputTerminal(borrowTunnel.InputTerminals[0], NITypes.Int32, 0, true);
            Wire.Create(function.BlockDiagram, sliceToIterator.OutputTerminals[0], iterateTunnel.InputTerminals[0])
            .SetWireBeginsMutableVariable(true);
            FunctionalNode accumulateAdd = new FunctionalNode(loop.Diagrams[0], Signatures.DefineMutatingBinaryFunction("AccumulateAdd", NITypes.Int32));

            Wire.Create(loop.Diagrams[0], borrowTunnel.OutputTerminals[0], accumulateAdd.InputTerminals[0]);
            Wire.Create(loop.Diagrams[0], iterateTunnel.OutputTerminals[0], accumulateAdd.InputTerminals[1]);
            FunctionalNode inspectNode = ConnectInspectToOutputTerminal(borrowTunnel.TerminateLifetimeTunnel.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspectNode);
            AssertByteArrayIsInt32(inspectValue, 16);
        }
        public void OpenFileHandleAndReadLine_Execute_LineReadFromFile()
        {
            string       filePath = Path.Combine(TestContext.DeploymentDirectory, Path.GetRandomFileName());
            const string data     = "data";

            CreateFileAndWriteData(filePath, data + "\r\n");
            DfirRoot           function       = DfirRoot.Create();
            FunctionalNode     openFileHandle = new FunctionalNode(function.BlockDiagram, Signatures.OpenFileHandleType);
            Constant           pathConstant   = ConnectStringConstantToInputTerminal(openFileHandle.InputTerminals[0], filePath);
            Frame              frame          = Frame.Create(function.BlockDiagram);
            UnwrapOptionTunnel unwrapOption   = new UnwrapOptionTunnel(frame);

            Wire.Create(function.BlockDiagram, openFileHandle.OutputTerminals[1], unwrapOption.InputTerminals[0]);
            FunctionalNode readLineFromFileHandle = new FunctionalNode(frame.Diagram, Signatures.ReadLineFromFileHandleType);

            Wire.Create(frame.Diagram, unwrapOption.OutputTerminals[0], readLineFromFileHandle.InputTerminals[0]);
            Frame innerFrame = Frame.Create(frame.Diagram);
            UnwrapOptionTunnel innerUnwrapOption = new UnwrapOptionTunnel(innerFrame);

            Wire.Create(frame.Diagram, readLineFromFileHandle.OutputTerminals[1], innerUnwrapOption.InputTerminals[0]);
            FunctionalNode output = new FunctionalNode(innerFrame.Diagram, Signatures.OutputType);

            Wire.Create(innerFrame.Diagram, innerUnwrapOption.OutputTerminals[0], output.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.AreEqual(data, executionInstance.RuntimeServices.LastOutputValue);
        }
예제 #10
0
        public void PanickingMethodCallWithTwoOutputsThatDoesNotPanicIntoAdd_Execute_CorrectValue()
        {
            using (FeatureToggleSupport.TemporarilyEnableFeature(RebarFeatureToggles.ParametersAndCalls))
            {
                string calleeName = "callee";
                NIType calleeType = DefineFunctionTypeWithTwoIntOuts(calleeName);
                CompilableDefinitionName calleeDefinitionName = CreateTestCompilableDefinitionName(calleeName);
                DfirRoot       calleeFunction      = calleeType.CreateFunctionFromSignature(calleeDefinitionName);
                DataAccessor   outputDataAccessor0 = DataAccessor.Create(calleeFunction.BlockDiagram, calleeFunction.DataItems[0], Direction.Input);
                DataAccessor   outputDataAccessor1 = DataAccessor.Create(calleeFunction.BlockDiagram, calleeFunction.DataItems[1], Direction.Input);
                FunctionalNode unwrap = new FunctionalNode(calleeFunction.BlockDiagram, Signatures.UnwrapOptionType);
                ConnectSomeOfIntegerToInputTerminal(unwrap.InputTerminals[0], 1);
                Wire.Create(calleeFunction.BlockDiagram, unwrap.OutputTerminals[0], outputDataAccessor0.Terminal, outputDataAccessor1.Terminal);
                DfirRoot       callerFunction = DfirRoot.Create();
                var            methodCall     = new MethodCallNode(callerFunction.BlockDiagram, calleeDefinitionName, calleeType);
                FunctionalNode add            = new FunctionalNode(callerFunction.BlockDiagram, Signatures.DefinePureBinaryFunction("Add", NITypes.Int32, NITypes.Int32));
                Wire.Create(callerFunction.BlockDiagram, methodCall.OutputTerminals[0], add.InputTerminals[0]);
                Wire.Create(callerFunction.BlockDiagram, methodCall.OutputTerminals[1], add.InputTerminals[1]);
                FunctionalNode inspect = ConnectInspectToOutputTerminal(add.OutputTerminals[2]);

                TestExecutionInstance executionInstance = CompileAndExecuteFunction(callerFunction, calleeFunction);

                byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
                AssertByteArrayIsInt32(inspectValue, 2);
            }
        }
예제 #11
0
        public void CreateDroppableValue_Execute_ValueIsDropped()
        {
            DfirRoot       function       = DfirRoot.Create();
            FunctionalNode fakeDropCreate = CreateFakeDropWithId(function.BlockDiagram, 1);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.DroppedFakeDropIds.Contains(1));
        }
예제 #12
0
        private byte[] CreateAndExecuteFunctionWithConstantAndInspect(NIType constantType, object constantValue)
        {
            DfirRoot              function          = DfirRoot.Create();
            FunctionalNode        inspect           = new FunctionalNode(function.BlockDiagram, Signatures.InspectType);
            Constant              constant          = ConnectConstantToInputTerminal(inspect.InputTerminals[0], constantType, constantValue, false);
            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            return(executionInstance.GetLastValueFromInspectNode(inspect));
        }
예제 #13
0
        private string CreateAndExecuteFunctionWithConstantAndOutput(NIType constantType, object constantValue)
        {
            DfirRoot              function          = DfirRoot.Create();
            FunctionalNode        output            = new FunctionalNode(function.BlockDiagram, Signatures.OutputType);
            Constant              constant          = ConnectConstantToInputTerminal(output.InputTerminals[0], constantType, constantValue, false);
            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            return(executionInstance.RuntimeServices.LastOutputValue);
        }
예제 #14
0
        public void InitializeVectorAndSliceIndexWithNegativeIndex_Execute_NoElementValueReturned()
        {
            const int elementValue = 5;
            var       tuple        = CreateInitializeVectorAndSliceIndexFunction(elementValue, -1);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(tuple.Item1);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(tuple.Item2);
            AssertByteArrayIsInt32(inspectValue, 0);
        }
예제 #15
0
        public void PanickingUnwrapOptionIntoOutput_Execute_RuntimeRegistersPanic()
        {
            DfirRoot       function     = DfirRoot.Create();
            FunctionalNode unwrapOption = CreatePanickingUnwrapOption(function.BlockDiagram);

            ConnectOutputToOutputTerminal(unwrapOption.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.PanicOccurred);
        }
예제 #16
0
        public void PanickingUnwrapOptionIntoOutput_Execute_NoOutputValue()
        {
            DfirRoot       function     = DfirRoot.Create();
            FunctionalNode unwrapOption = CreatePanickingUnwrapOption(function.BlockDiagram);

            ConnectOutputToOutputTerminal(unwrapOption.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsNull(executionInstance.RuntimeServices.LastOutputValue, "Expected no output value to be written.");
        }
        public void OptionPatternStructureWithOutputTunnelAndNoneValueWiredToSelector_Execute_CorrectValueFromOutputTunnel()
        {
            DfirRoot function = CreateOptionPatternStructureWithOutputTunnelAndInspect(false, 0, 1);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            var inspectNode = function.BlockDiagram.Nodes.OfType <FunctionalNode>().Where(f => f.Signature == Signatures.InspectType).First();

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspectNode);
            AssertByteArrayIsInt32(inspectValue, 1);
        }
예제 #18
0
        public void VariantConstructorContainingDroppableValue_Execute_ValueIsDropped()
        {
            DfirRoot       function = DfirRoot.Create();
            var            variantConstructorNode = new VariantConstructorNode(function.BlockDiagram, VariantWithDropField, 1);
            FunctionalNode createFakeDrop         = CreateFakeDropWithId(function.BlockDiagram, 1);

            Wire.Create(function.BlockDiagram, createFakeDrop.OutputTerminals[0], variantConstructorNode.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.DroppedFakeDropIds.Contains(1));
        }
예제 #19
0
        public void StructConstructorContainingDroppableType_Execute_DroppableValueDropped()
        {
            DfirRoot       function = DfirRoot.Create();
            var            structConstructorNode = new StructConstructorNode(function.BlockDiagram, FakeDropStructType);
            FunctionalNode fakeDrop = CreateFakeDropWithId(function.BlockDiagram, 1);

            Wire.Create(function.BlockDiagram, fakeDrop.OutputTerminals[0], structConstructorNode.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.DroppedFakeDropIds.Contains(1));
        }
예제 #20
0
        public void DropSomeValueWithDroppableInnerValue_Execute_InnerValueIsDropped()
        {
            DfirRoot       function        = DfirRoot.Create();
            FunctionalNode someConstructor = new FunctionalNode(function.BlockDiagram, Signatures.SomeConstructorType);
            FunctionalNode fakeDropCreate  = CreateFakeDropWithId(function.BlockDiagram, 1);

            Wire.Create(function.BlockDiagram, fakeDropCreate.OutputTerminals[0], someConstructor.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.DroppedFakeDropIds.Contains(1));
        }
예제 #21
0
        public void NonPanickingUnwrapOptionIntoInspect_Execute_CorrectValue()
        {
            DfirRoot function     = DfirRoot.Create();
            var      unwrapOption = new FunctionalNode(function.BlockDiagram, Signatures.UnwrapOptionType);

            ConnectSomeOfIntegerToInputTerminal(unwrapOption.InputTerminals[0], 5, false);
            FunctionalNode inspect = ConnectInspectToOutputTerminal(unwrapOption.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            AssertByteArrayIsInt32(inspectValue, 5);
        }
예제 #22
0
        public void CreateYieldPromiseAndAwait_Execute_ExecutionFinishesAndYieldedValueReadFromInspect()
        {
            DfirRoot function  = DfirRoot.Create();
            var      yieldNode = new FunctionalNode(function.BlockDiagram, Signatures.YieldType);

            ConnectConstantToInputTerminal(yieldNode.InputTerminals[0], NITypes.Int32, 5, false);
            FunctionalNode inspect = ConnectInspectToOutputTerminal(yieldNode.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            AssertByteArrayIsInt32(inspectValue, 5);
        }
        public void StringSliceConstantToOutput_Execute_CorrectStringOutput()
        {
            DfirRoot       function        = DfirRoot.Create();
            FunctionalNode output          = new FunctionalNode(function.BlockDiagram, Signatures.OutputType);
            FunctionalNode stringFromSlice = new FunctionalNode(function.BlockDiagram, Signatures.StringFromSliceType);

            Wire.Create(function.BlockDiagram, stringFromSlice.OutputTerminals[1], output.InputTerminals[0]);
            Constant stringConstant = ConnectStringConstantToInputTerminal(stringFromSlice.InputTerminals[0], "test");

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.AreEqual("test", executionInstance.RuntimeServices.LastOutputValue);
        }
        public void OptionPatternStructureSelectorWiredToInspectOnSomeValueDiagram_Execute_CorrectValue()
        {
            DfirRoot function = DfirRoot.Create();
            OptionPatternStructure patternStructure = CreateOptionPatternStructureWithOptionValueWiredToSelector(function.BlockDiagram, 1);
            FunctionalNode         someInspectNode  = new FunctionalNode(patternStructure.Diagrams[0], Signatures.InspectType);

            Wire.Create(patternStructure.Diagrams[0], patternStructure.Selector.OutputTerminals[0], someInspectNode.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(someInspectNode);
            AssertByteArrayIsInt32(inspectValue, 1);
        }
예제 #25
0
        public void PanickingUnwrapOptionInsideLoopDiagram_Execute_LoopTerminatesAndDownstreamOfLoopDoesNotExecute()
        {
            DfirRoot            function  = DfirRoot.Create();
            Loop                loop      = new Loop(function.BlockDiagram);
            LoopConditionTunnel condition = CreateLoopConditionTunnel(loop);
            FunctionalNode      unwrap    = CreatePanickingUnwrapOption(loop.Diagram);

            ConnectOutputToOutputTerminal(condition.TerminateLifetimeTunnel.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            AssertNoOutput(executionInstance);
        }
예제 #26
0
        public void PanickingUnwrapOptionIntoFrame_Execute_FrameDoesNotExecute()
        {
            DfirRoot       function    = DfirRoot.Create();
            FunctionalNode unwrap      = CreatePanickingUnwrapOption(function.BlockDiagram);
            Frame          frame       = Frame.Create(function.BlockDiagram);
            Tunnel         inputTunnel = CreateInputTunnel(frame);

            Wire.Create(function.BlockDiagram, unwrap.OutputTerminals[0], inputTunnel.InputTerminals[0]);
            ConnectOutputToOutputTerminal(inputTunnel.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            AssertNoOutput(executionInstance);
        }
예제 #27
0
        public void SelectReferenceWithFalseSelector_Execute_CorrectSelectedResult()
        {
            DfirRoot       function           = DfirRoot.Create();
            FunctionalNode selectReference    = new FunctionalNode(function.BlockDiagram, Signatures.SelectReferenceType);
            Constant       selectorConstant   = ConnectConstantToInputTerminal(selectReference.InputTerminals[0], NITypes.Boolean, false, false);
            Constant       trueValueConstant  = ConnectConstantToInputTerminal(selectReference.InputTerminals[1], NITypes.Int32, 1, false);
            Constant       falseValueConstant = ConnectConstantToInputTerminal(selectReference.InputTerminals[2], NITypes.Int32, 0, false);
            FunctionalNode inspect            = ConnectInspectToOutputTerminal(selectReference.OutputTerminals[1]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            AssertByteArrayIsInt32(inspectValue, 0);
        }
예제 #28
0
        public void CreateSharedOfDroppableValueAndClone_Execute_InnerValueDropped()
        {
            DfirRoot       function       = DfirRoot.Create();
            FunctionalNode fakeDropCreate = CreateFakeDropWithId(function.BlockDiagram, 1);
            FunctionalNode createShared   = new FunctionalNode(function.BlockDiagram, Signatures.SharedCreateType);

            Wire.Create(function.BlockDiagram, fakeDropCreate.OutputTerminals[0], createShared.InputTerminals[0]);
            FunctionalNode createCopy = new FunctionalNode(function.BlockDiagram, Signatures.CreateCopyType);

            Wire.Create(function.BlockDiagram, createShared.OutputTerminals[0], createCopy.InputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            Assert.IsTrue(executionInstance.RuntimeServices.DroppedFakeDropIds.Contains(1));
        }
예제 #29
0
        public void AssignOptionValueToNoneValue_Execute_CorrectFinalValue()
        {
            DfirRoot       function = DfirRoot.Create();
            FunctionalNode assign, inspect;

            CreateAssignToSomeInt32ValueAndInspect(function.BlockDiagram, out assign, out inspect);
            FunctionalNode finalNone = new FunctionalNode(function.BlockDiagram, Signatures.NoneConstructorType);

            Wire.Create(function.BlockDiagram, finalNone.OutputTerminals[0], assign.InputTerminals[1]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            AssertByteArrayIsNoneInteger(inspectValue);
        }
예제 #30
0
        public void FunctionWithRangeWithInt32Inputs_Execute_CorrectRangeValue()
        {
            DfirRoot       function  = DfirRoot.Create();
            FunctionalNode range     = new FunctionalNode(function.BlockDiagram, Signatures.RangeType);
            Constant       lowValue  = ConnectConstantToInputTerminal(range.InputTerminals[0], NITypes.Int32, 0, false);
            Constant       highValue = ConnectConstantToInputTerminal(range.InputTerminals[1], NITypes.Int32, 10, false);
            FunctionalNode inspect   = ConnectInspectToOutputTerminal(range.OutputTerminals[0]);

            TestExecutionInstance executionInstance = CompileAndExecuteFunction(function);

            byte[] inspectValue = executionInstance.GetLastValueFromInspectNode(inspect);
            Assert.AreEqual(8, inspectValue.Length);
            Assert.AreEqual(-1, BitConverter.ToInt32(inspectValue, 0));
            Assert.AreEqual(10, BitConverter.ToInt32(inspectValue, 4));
        }