Example #1
0
        public void TypeDiagram_InferTypes_DefinedTypeNameMatchesDfirRootName()
        {
            DfirRoot typeDiagram  = DfirRoot.Create(CreateTestCompilableDefinitionName("type"));
            var      selfTypeNode = new SelfTypeNode(typeDiagram.BlockDiagram, SelfTypeMode.Struct, 1);

            ConnectPrimitiveTypeToInputTerminal(selfTypeNode.InputTerminals[0], NITypes.Int32);

            RunSemanticAnalysisUpToTypeInference(typeDiagram);

            NIType selfType = typeDiagram.GetSelfType();

            Assert.AreEqual("type", selfType.GetName());
        }
Example #2
0
        public void PrimitivesIntoSelfVariantType_InferTypes_SelfTypeIsUnionType()
        {
            DfirRoot typeDiagram  = DfirRoot.Create(CreateTestCompilableDefinitionName("type"));
            var      selfTypeNode = new SelfTypeNode(typeDiagram.BlockDiagram, SelfTypeMode.Variant, 2);

            ConnectPrimitiveTypeToInputTerminal(selfTypeNode.InputTerminals[0], NITypes.Int32);
            ConnectPrimitiveTypeToInputTerminal(selfTypeNode.InputTerminals[1], NITypes.Boolean);

            RunSemanticAnalysisUpToTypeInference(typeDiagram);

            NIType selfType = typeDiagram.GetSelfType();

            Assert.IsTrue(selfType.IsUnion());
            Assert.AreEqual(2, selfType.GetFields().Count());
        }
Example #3
0
        public void PrimitiveTypeIntoSelf_InferTypes_SelfTypeIsPrimitiveType()
        {
            DfirRoot typeDiagram  = DfirRoot.Create(CreateTestCompilableDefinitionName("type"));
            var      selfTypeNode = new SelfTypeNode(typeDiagram.BlockDiagram, SelfTypeMode.Struct, 1);

            ConnectPrimitiveTypeToInputTerminal(selfTypeNode.InputTerminals[0], NITypes.Int32);

            RunSemanticAnalysisUpToTypeInference(typeDiagram);

            NIType selfType = typeDiagram.GetSelfType();

            Assert.IsTrue(selfType.IsValueClass());
            Assert.AreEqual(1, selfType.GetFields().Count());
            Assert.IsTrue(selfType.GetFields().ElementAt(0).GetDataType().IsInt32());
        }