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 })); }
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 })); }
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); } }