Example #1
0
        static void Main(string[] args)
        {
            var before   = "a or (a or b)";
            var after    = "a or b";
            var examples = new List <Tuple <string, string> >()
            {
                Tuple.Create(before, after)
            };
            var refazer        = new Refazer4Python();
            var transformation = refazer.LearnTransformations(examples.ToList()).First();

            foreach (var mistake in examples)
            {
                var output = refazer.Apply(transformation, mistake.Item1);
                Console.Out.WriteLine("");
                var isFixed = false;
                foreach (var newCode in output)
                {
                    var unparser = new Unparser();
                    isFixed = mistake.Item2.Equals(newCode);
                    if (isFixed)
                    {
                        break;
                    }
                }
                Console.WriteLine("Before: " + mistake.Item1);
                Console.WriteLine("Expected After: " + mistake.Item2);
                Console.WriteLine("Actual After: " + output.FirstOrDefault());
                Console.WriteLine(isFixed);
            }
        }
Example #2
0
        public static void AssertCorrectTransformation(IEnumerable <Tuple <string, string> > examples)
        {
            var refazer        = new Refazer4Python();
            var transformation = refazer.LearnTransformations(examples.ToList()).First();

            foreach (var mistake in examples)
            {
                var output = refazer.Apply(transformation, mistake.Item1);
                Console.Out.WriteLine("");
                var isFixed = false;
                foreach (var newCode in output)
                {
                    var unparser = new Unparser();
                    isFixed = mistake.Item2.Equals(newCode);
                    if (isFixed)
                    {
                        break;
                    }
                }
                Assert.IsTrue(isFixed);
            }
        }