Ejemplo n.º 1
0
        public void EvaluateMultiFunctionWithTwoFunctions()
        {
            Function func1 = this.MakeFunction("f(0) -> 1.");
            Function func2 = this.MakeFunction("f(1) -> 2.");
            MultiFunction mfunc = new MultiFunction(new Function[] { func1, func2 });

            Assert.AreEqual(2, mfunc.Apply(null, new object[] { 1 }));
        }
Ejemplo n.º 2
0
        public void EvaluateMultiFunctionWithTwoFunctions()
        {
            Function      func1 = this.MakeFunction("f(0) -> 1.");
            Function      func2 = this.MakeFunction("f(1) -> 2.");
            MultiFunction mfunc = new MultiFunction(new Function[] { func1, func2 });

            Assert.AreEqual(2, mfunc.Apply(null, new object[] { 1 }));
        }
Ejemplo n.º 3
0
        public void EvaluateMultiFunctionWithOneFunction()
        {
            Function func = this.MakeFunction("f(0) -> 1.");
            MultiFunction mfunc = new MultiFunction(new Function[] { func });

            Assert.IsNotNull(mfunc.Functions);
            Assert.AreEqual(1, mfunc.Functions.Count);

            Assert.AreEqual(1, mfunc.Apply(null, new object[] { 0 }));
        }
Ejemplo n.º 4
0
        public void EvaluateMultiFunctionWithOneFunction()
        {
            Function      func  = this.MakeFunction("f(0) -> 1.");
            MultiFunction mfunc = new MultiFunction(new Function[] { func });

            Assert.IsNotNull(mfunc.Functions);
            Assert.AreEqual(1, mfunc.Functions.Count);

            Assert.AreEqual(1, mfunc.Apply(null, new object[] { 0 }));
        }
Ejemplo n.º 5
0
        public void RaiseIfNoClauseToMatch()
        {
            Function func1 = this.MakeFunction("f(0) -> 1.");
            Function func2 = this.MakeFunction("f(1) -> 2.");
            MultiFunction mfunc = new MultiFunction(new Function[] { func1, func2 });

            try
            {
                mfunc.Apply(null, new object[] { 2 });
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("no function clause to match", ex.Message);
            }
        }
Ejemplo n.º 6
0
        public void RaiseIfNoClauseToMatch()
        {
            Function      func1 = this.MakeFunction("f(0) -> 1.");
            Function      func2 = this.MakeFunction("f(1) -> 2.");
            MultiFunction mfunc = new MultiFunction(new Function[] { func1, func2 });

            try
            {
                mfunc.Apply(null, new object[] { 2 });
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("no function clause to match", ex.Message);
            }
        }