Ejemplo n.º 1
0
        public void TestLogicConde()
        {
            /*
             * x = var('x')
             * assert results(conde([eq(x, 2)], [eq(x, 3)])) == ({x: 2}, {x: 3})
             * assert results(conde([eq(x, 2), eq(x, 3)])) == ()
             */
            var x     = new Var('x');
            var goal1 = new EqGoal(x, 2);
            var goal2 = new EqGoal(x, 3);
            var lst   = new List <Goal>();

            lst.Add(goal1);
            var lst2 = new List <Goal>();

            lst2.Add(goal2);
            var lslst = new List <List <Goal> >();

            lslst.Add(lst);
            lslst.Add(lst2);

            var    dict   = new Dictionary <object, object>();
            object result = LogicSharp.logic_Conde(lslst, dict);

            Assert.IsInstanceOf(typeof(IEnumerable <KeyValuePair <object, object> >), result);
            Assert.IsInstanceOf(typeof(HashSet <KeyValuePair <object, object> >), result);
            var myHashSet = result as HashSet <KeyValuePair <object, object> >;

            Assert.NotNull(myHashSet);
            Assert.True(myHashSet.Count == 2);

            lst = new List <Goal>();
            lst.Add(goal1);
            lst.Add(goal2);
            lslst = new List <List <Goal> >();
            lslst.Add(lst);
            dict   = new Dictionary <object, object>();
            result = LogicSharp.logic_Conde(lslst, dict);
            Assert.IsInstanceOf(typeof(IEnumerable <KeyValuePair <object, object> >), result);
            Assert.IsInstanceOf(typeof(HashSet <KeyValuePair <object, object> >), result);
            myHashSet = result as HashSet <KeyValuePair <object, object> >;
            Assert.IsEmpty(myHashSet);
        }