Skip to content

Commit

Permalink
chore: Update DynamicExpresso to v2.6.0
Browse files Browse the repository at this point in the history
Signed-off-by: Sagilio <[email protected]>
  • Loading branch information
sagilio committed Jun 4, 2021
1 parent 7a720f0 commit 174feab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions NetCasbin.UnitTest/UtilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@ namespace NetCasbin.UnitTest
{
public class UtilityTest
{
private delegate bool GFunction(string arg = null);
private delegate bool GFunction(string a, string b, string arg = null);

[Fact]
public void TestParseGFunction()
{
static bool GetGFunction(string arg = null)
const string name = "a";
bool GetGFunction(string a, string b, string arg = null)
{
return arg is not null;
};
if (arg is not null)
{
return a == name;
}
return b == name;
}

var interpreter = new Interpreter();
interpreter.SetFunction("GFunction", (GFunction) GetGFunction);

interpreter.SetVariable("arg", "arg");
interpreter.SetVariable("a", "a");
interpreter.SetVariable("b", "b");

Assert.True((bool) interpreter.Eval("GFunction(arg)"));
Assert.False((bool) interpreter.Eval("GFunction()"));
Assert.True((bool) interpreter.Eval("GFunction(a, b, arg)"));
Assert.False((bool) interpreter.Eval("GFunction(a, b)"));
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion NetCasbin/NetCasbin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DynamicExpresso.Core" Version="2.4.1" />
<PackageReference Include="DynamicExpresso.Core" Version="2.6.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>

Expand Down

0 comments on commit 174feab

Please sign in to comment.