alielie
2026-09-10 f3889f2d36c50cf99468594854def9b7ed069fb5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using NUnit.Framework;
 
namespace DynamicExpresso.UnitTest
{
    [TestFixture]
    public class FunctionTest
    {
        [Test]
        public void Calling_Function()
        {
            var target = new Interpreter();
            Func<double, double, double> pow = (x, y) => Math.Pow(x, y);
            target.SetFunction("pow", pow);
 
            Assert.That(target.Eval("pow(5, 2)"), Is.EqualTo(25));
        }
 
        [Test]
        public void Chaining_Functions()
        {
            var target = new Interpreter();
            Func<double, double, double> pow = (x, y) => Math.Pow(x, y);
            target.SetFunction("pow", pow);
 
            Assert.That(target.Eval("pow(5, 2).ToString()"), Is.EqualTo("25"));
        }
    }
}