Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public override Expression VisitLogicalExpression([NotNull] SimpleflowParser.Log
switch (symbolType)
{
case SimpleflowLexer.And:
return Expression.And(left, right);
return Expression.AndAlso(left, right);

case SimpleflowLexer.Or:
return Expression.Or(left, right);
return Expression.OrElse(left, right);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Simpleflow/Simpleflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net48;netcoreapp3.1;net6.0;</TargetFrameworks>
<PackageIcon>PackageIcon.png</PackageIcon>
<VersionPrefix>1.0.11</VersionPrefix>
<VersionSuffix>beta3</VersionSuffix>
<VersionSuffix>beta4</VersionSuffix>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
27 changes: 26 additions & 1 deletion test/Simpleflow.Tests/Scripting/PredicateStatementsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using Xunit;
using Simpleflow.Tests.Helpers;

using System.Collections.Generic;

namespace Simpleflow.Tests.Scripting
{
Expand Down Expand Up @@ -153,5 +153,30 @@ rule when d2 < d1 then
Assert.Single(output.Messages);
}


[Fact]
public void CheckShortCircuitingAndOperator()
{
// Arrange

var script =
@"
rule when $exists(dict: arg, key: 'ContentType') and arg['ContentType'] == none then
message 'got it'
";

FlowOutput output = SimpleflowEngine.Run(script,
new Dictionary<string, object> { {"test", null } }
,
new FunctionRegister().Add("exists", (System.Func<IDictionary<string, object>, string, bool>)Exists));

Assert.Empty(output.Messages);
}

public static bool Exists(IDictionary<string, object> dict, string key)
{
return dict.ContainsKey(key);
}

}
}