コード例 #1
0
        public void AddStackDependencyWithMultipleSourcesShouldSetDegree()
        {
            var graph = new DataFlowGraph <int>(IntArchitecture.Instance);

            var n1 = graph.Nodes.Add(1, 1);
            var n2 = graph.Nodes.Add(2, 2);
            var n3 = graph.Nodes.Add(3, 3);

            Assert.Equal(0, n1.OutDegree);

            var dependency = new StackDependency <int>();

            n1.StackDependencies.Add(dependency);
            dependency.Add(n2);
            dependency.Add(n3);

            Assert.Equal(2, n1.OutDegree);
        }
コード例 #2
0
        public void AddStackDependencyShouldSetDependant()
        {
            var dfg = new DataFlowGraph <int>(IntArchitecture.Instance);
            var n0  = dfg.Nodes.Add(0, 0);
            var n1  = dfg.Nodes.Add(1, 1);

            var dependency = new StackDependency <int>();

            n1.StackDependencies.Add(dependency);
            dependency.Add(n0);

            Assert.Same(n1, dependency.Dependent);
        }
コード例 #3
0
        public void RemoveStackDependencyShouldUnsetDependant()
        {
            var dfg = new DataFlowGraph <int>(IntArchitecture.Instance);
            var n0  = dfg.Nodes.Add(0, 0);
            var n1  = dfg.Nodes.Add(1, 1);

            var symbolicValue = new StackDependency <int>();

            n1.StackDependencies.Add(symbolicValue);
            symbolicValue.Add(n0);

            n1.StackDependencies.Remove(symbolicValue);
            Assert.Null(symbolicValue.Dependent);
        }
コード例 #4
0
        public void AddStackDependencyShouldAddToDependants()
        {
            var dfg = new DataFlowGraph <int>(IntArchitecture.Instance);
            var n0  = dfg.Nodes.Add(0, 0);
            var n1  = dfg.Nodes.Add(1, 1);
            var n2  = dfg.Nodes.Add(2, 2);

            var dependency1 = new StackDependency <int>();

            n1.StackDependencies.Add(dependency1);
            dependency1.Add(n0);

            var dependency2 = new StackDependency <int>();

            n2.StackDependencies.Add(dependency2);
            dependency2.Add(n0);

            Assert.Equal(new HashSet <DataFlowNode <int> >
            {
                n1, n2
            }, new HashSet <DataFlowNode <int> >(n0.GetDependants()));
        }