コード例 #1
0
        public virtual void TestCyclicGraph()
        {
            Graph g = new Graph();
            g.AddEdge( "A", "B" );
            g.AddEdge( "B", "C" );
            g.AddEdge( "C", "A" );
            g.AddEdge( "C", "D" );

            string expecting = "[D, C, B, A]";
            var nodes = g.Sort();
            string result = nodes.ToElementString();
            Assert.AreEqual( expecting, result );
        }
コード例 #2
0
        public virtual void TestParserLexerCombo()
        {
            Graph g = new Graph();
            g.AddEdge( "JavaLexer.tokens", "JavaLexer.g" );
            g.AddEdge( "JavaParser.g", "JavaLexer.tokens" );
            g.AddEdge( "Def.g", "JavaLexer.tokens" );
            g.AddEdge( "Ref.g", "JavaLexer.tokens" );

            string expecting = "[JavaLexer.g, JavaLexer.tokens, JavaParser.g, Def.g, Ref.g]";
            var nodes = g.Sort();
            string result = nodes.ToElementString();
            Assert.AreEqual( expecting, result );
        }
コード例 #3
0
        public virtual void TestFairlyLargeGraph()
        {
            Graph g = new Graph();
            g.AddEdge( "C", "F" );
            g.AddEdge( "C", "G" );
            g.AddEdge( "C", "A" );
            g.AddEdge( "C", "B" );
            g.AddEdge( "A", "D" );
            g.AddEdge( "A", "E" );
            g.AddEdge( "B", "E" );
            g.AddEdge( "D", "E" );
            g.AddEdge( "D", "F" );
            g.AddEdge( "F", "H" );
            g.AddEdge( "E", "F" );
            g.AddEdge( "G", "A" );

            string expecting = "[H, F, E, D, A, G, B, C]";
            var nodes = g.Sort();
            string result = nodes.ToElementString();
            Assert.AreEqual( expecting, result );
        }
コード例 #4
0
        public virtual void TestSimpleTokenDependence()
        {
            Graph g = new Graph();
            g.AddEdge( "Java.g", "MyJava.tokens" ); // Java feeds off manual token file
            g.AddEdge( "Java.tokens", "Java.g" );
            g.AddEdge( "Def.g", "Java.tokens" );    // walkers feed off generated tokens
            g.AddEdge( "Ref.g", "Java.tokens" );

            string expecting = "[MyJava.tokens, Java.g, Java.tokens, Def.g, Ref.g]";
            var nodes = g.Sort();
            string result = nodes.ToElementString();
            Assert.AreEqual( expecting, result );
        }
コード例 #5
0
        public virtual void TestRepeatedEdges()
        {
            Graph g = new Graph();
            g.AddEdge( "A", "B" );
            g.AddEdge( "B", "C" );
            g.AddEdge( "A", "B" ); // dup
            g.AddEdge( "C", "D" );

            string expecting = "[D, C, B, A]";
            var nodes = g.Sort();
            string result = nodes.ToElementString();
            assertEquals( expecting, result );
        }