Example #1
0
        public void TestUnion()
        {
            var pgm = Parser.ParseFromFile(srcDirectory + "Fast.Tests/FastSamples/union.fast");

            FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm);

            var t1   = fti.treeDefinitions["A"].trees["t_1"];
            var t2   = fti.treeDefinitions["A"].trees["t_2"];
            var t12  = fti.treeDefinitions["A"].trees["t_12"];
            var tnot = fti.treeDefinitions["A"].trees["t_not"];

            var q1    = fti.treeDefinitions["A"].acceptors["q1"];
            var r1    = fti.treeDefinitions["A"].acceptors["r1"];
            var union = fti.treeDefinitions["A"].acceptors["union_q1r1"];



            //StringBuilder sb = new StringBuilder();

            //fti.ToFast(sb);
            //var pgm2 = Parser.ParseFromString(sb.ToString());


            //Assert.IsTrue(q1.Apply(t12).SequenceEqual(union.Apply(t12)));
            // Assert.IsTrue(r1.Apply(t12).SequenceEqual(union.Apply(t12)));
            //Assert.IsTrue(q1.Apply(t1).SequenceEqual(union.Apply(t1)));


            var res1 = new Microsoft.Automata.Sequence <Expr>(r1.Apply(t1));

            Assert.IsTrue(res1.Length == 0);

            var res2 = new Microsoft.Automata.Sequence <Expr>(union.Apply(t1));

            Assert.IsTrue(res2.Length == 1);



            Assert.IsFalse(q1.Apply(t2).SequenceEqual(union.Apply(t2)));


            Assert.IsTrue(r1.Apply(t2).SequenceEqual(union.Apply(t2)));
            Assert.IsTrue(q1.Apply(tnot).SequenceEqual(union.Apply(tnot)));
            Assert.IsTrue(r1.Apply(tnot).SequenceEqual(union.Apply(tnot)));


            //bool b = CsharpGenerator.GenerateCode(pgm, "../../../src/Fast.Tests/GeneratedCS/union.cs", "Microsoft.Fast.Tests.Intersection");
        }
Example #2
0
        public void TestUnion()
        {
            var pgm = Parser.ParseFromFile(srcDirectory + "Fast.Tests/FastSamples/union.fast");

            FastTransducerInstance fti = FastTransducerInstance.MkFastTransducerInstance(pgm);

            var t1 = fti.treeDefinitions["A"].trees["t_1"];
            var t2 = fti.treeDefinitions["A"].trees["t_2"];
            var t12 = fti.treeDefinitions["A"].trees["t_12"];
            var tnot = fti.treeDefinitions["A"].trees["t_not"];

            var q1 = fti.treeDefinitions["A"].acceptors["q1"];
            var r1 = fti.treeDefinitions["A"].acceptors["r1"];
            var union = fti.treeDefinitions["A"].acceptors["union_q1r1"];

            //StringBuilder sb = new StringBuilder();

            //fti.ToFast(sb);
            //var pgm2 = Parser.ParseFromString(sb.ToString());

            //Assert.IsTrue(q1.Apply(t12).SequenceEqual(union.Apply(t12)));
               // Assert.IsTrue(r1.Apply(t12).SequenceEqual(union.Apply(t12)));
            //Assert.IsTrue(q1.Apply(t1).SequenceEqual(union.Apply(t1)));

            var res1 = new Microsoft.Automata.Sequence<Expr>(r1.Apply(t1));
            Assert.IsTrue(res1.Length == 0);

            var res2 = new Microsoft.Automata.Sequence<Expr>(union.Apply(t1));
            Assert.IsTrue(res2.Length == 1);

            Assert.IsFalse(q1.Apply(t2).SequenceEqual(union.Apply(t2)));

            Assert.IsTrue(r1.Apply(t2).SequenceEqual(union.Apply(t2)));
            Assert.IsTrue(q1.Apply(tnot).SequenceEqual(union.Apply(tnot)));
            Assert.IsTrue(r1.Apply(tnot).SequenceEqual(union.Apply(tnot)));

            //bool b = CsharpGenerator.GenerateCode(pgm, "../../../src/Fast.Tests/GeneratedCS/union.cs", "Microsoft.Fast.Tests.Intersection");
        }