Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        public void PanickingMethodCallWithInputAndOutputThatPanicsIntoOutput_Execute_NoOutputValue()
        {
            using (FeatureToggleSupport.TemporarilyEnableFeature(RebarFeatureToggles.ParametersAndCalls))
            {
                string calleeName = "callee";
                NIType calleeType = DefineFunctionTypeWithOptionIntInAndIntOut(calleeName);
                CompilableDefinitionName calleeDefinitionName = CreateTestCompilableDefinitionName(calleeName);
                DfirRoot       calleeFunction     = calleeType.CreateFunctionFromSignature(calleeDefinitionName);
                DataAccessor   inputDataAccessor  = DataAccessor.Create(calleeFunction.BlockDiagram, calleeFunction.DataItems[0], Direction.Output);
                DataAccessor   outputDataAccessor = DataAccessor.Create(calleeFunction.BlockDiagram, calleeFunction.DataItems[1], Direction.Input);
                FunctionalNode unwrap             = new FunctionalNode(calleeFunction.BlockDiagram, Signatures.UnwrapOptionType);
                Wire.Create(calleeFunction.BlockDiagram, inputDataAccessor.Terminal, unwrap.InputTerminals[0]);
                Wire.Create(calleeFunction.BlockDiagram, unwrap.OutputTerminals[0], outputDataAccessor.Terminal);
                DfirRoot       callerFunction = DfirRoot.Create();
                var            methodCall     = new MethodCallNode(callerFunction.BlockDiagram, calleeDefinitionName, calleeType);
                FunctionalNode noneInteger    = CreateNoneOfOptionIntegerType(callerFunction.BlockDiagram);
                Wire.Create(callerFunction.BlockDiagram, noneInteger.OutputTerminals[0], methodCall.InputTerminals[0]);
                ConnectOutputToOutputTerminal(methodCall.OutputTerminals[0]);

                TestExecutionInstance executionInstance = CompileAndExecuteFunction(callerFunction, calleeFunction);

                AssertNoOutput(executionInstance);
            }
        }