コード例 #1
0
ファイル: Core.cs プロジェクト: JakeCode11/CSharp.Logic
        public void TestLogicAll()
        {
/*            x = var('x')
 *          assert results(lall((eq, x, 2))) == ({x: 2},)
 *          assert results(lall((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);
            lst.Add(goal2);
            var    dict   = new Dictionary <object, object>();
            object result = LogicSharp.logic_All(lst, dict);

            Assert.Null(result);

            /*assert results(lall((eq, x, 2), (eq, y, 3))) == ({x:2, y:3}) */
            var y     = new Var('y');
            var goal3 = new EqGoal(y, 4);

            lst = new List <Goal>();
            lst.Add(goal1);
            lst.Add(goal3);
            dict   = new Dictionary <object, object>();
            result = LogicSharp.logic_All(lst, dict);
            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(Dictionary <object, object>), result);
            var resultDict = result as Dictionary <object, object>;

            Assert.IsTrue(resultDict.Count == 2);
        }