blob: ef1e6c3fe85a771d77f9ef9ecb7a5b9e52784800 [file] [log] [blame]
using DynamicExpresso;
using Xunit;
namespace Casbin.UnitTests.UtilTests;
public class UtilityTest
{
[Fact]
public void TestParseGFunction()
{
static bool GetGFunction(string arg = null)
{
return arg is not null;
}
Interpreter interpreter = new();
interpreter.SetFunction("GFunction", (GFunction)GetGFunction);
interpreter.SetVariable("arg", "arg");
Assert.True((bool)interpreter.Eval("GFunction(arg)"));
Assert.False((bool)interpreter.Eval("GFunction()"));
}
private delegate bool GFunction(string arg = null);
}