Rename BooleanExpression => ConditionExpression

This commit is contained in:
atlimit8
2017-02-05 20:25:34 -06:00
parent 0f3250f9b0
commit d83dae5587
7 changed files with 15 additions and 15 deletions

View File

@@ -398,13 +398,13 @@ namespace OpenRA
return InvalidValueAction(value, fieldType, fieldName);
}
else if (fieldType == typeof(BooleanExpression))
else if (fieldType == typeof(ConditionExpression))
{
if (value != null)
{
try
{
return new BooleanExpression(value);
return new ConditionExpression(value);
}
catch (InvalidDataException e)
{

View File

@@ -241,7 +241,7 @@
<Compile Include="Primitives\float3.cs" />
<Compile Include="InstalledMods.cs" />
<Compile Include="CryptoUtil.cs" />
<Compile Include="Support\BooleanExpression.cs" />
<Compile Include="Support\ConditionExpression.cs" />
<Compile Include="ExternalMods.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -16,7 +16,7 @@ using System.Linq;
namespace OpenRA.Support
{
public class BooleanExpression
public class ConditionExpression
{
public readonly string Expression;
readonly HashSet<string> variables = new HashSet<string>();
@@ -67,7 +67,7 @@ namespace OpenRA.Support
class NotEqualsToken : BinaryOperationToken { public NotEqualsToken(int index) : base("!=", index) { } }
class NotToken : UnaryOperationToken { public NotToken(int index) : base("!", index) { } }
public BooleanExpression(string expression)
public ConditionExpression(string expression)
{
Expression = expression;
var openParens = 0;

View File

@@ -29,9 +29,9 @@ namespace OpenRA.Mods.Common.Lint
if (typeof(IEnumerable<string>).IsAssignableFrom(type))
return fieldInfo.GetValue(ruleInfo) as IEnumerable<string>;
if (type == typeof(BooleanExpression))
if (type == typeof(ConditionExpression))
{
var expr = (BooleanExpression)fieldInfo.GetValue(ruleInfo);
var expr = (ConditionExpression)fieldInfo.GetValue(ruleInfo);
return expr != null ? expr.Variables : Enumerable.Empty<string>();
}
@@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Lint
if (typeof(IEnumerable).IsAssignableFrom(type))
return (IEnumerable<string>)propertyInfo.GetValue(ruleInfo);
if (type == typeof(BooleanExpression))
if (type == typeof(ConditionExpression))
{
var expr = (BooleanExpression)propertyInfo.GetValue(ruleInfo);
var expr = (ConditionExpression)propertyInfo.GetValue(ruleInfo);
return expr != null ? expr.Variables : Enumerable.Empty<string>();
}

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
[ConsumedConditionReference]
[Desc("Boolean expression defining the condition to enable this trait.")]
public readonly BooleanExpression RequiresCondition = null;
public readonly ConditionExpression RequiresCondition = null;
public abstract object Create(ActorInitializer init);

View File

@@ -19,7 +19,7 @@ using OpenRA.Support;
namespace OpenRA.Test
{
[TestFixture]
public class BooleanExpressionTest
public class ConditionExpressionTest
{
IReadOnlyDictionary<string, bool> testValues = new ReadOnlyDictionary<string, bool>(new Dictionary<string, bool>()
{
@@ -29,17 +29,17 @@ namespace OpenRA.Test
void AssertFalse(string expression)
{
Assert.False(new BooleanExpression(expression).Evaluate(testValues), expression);
Assert.False(new ConditionExpression(expression).Evaluate(testValues), expression);
}
void AssertTrue(string expression)
{
Assert.True(new BooleanExpression(expression).Evaluate(testValues), expression);
Assert.True(new ConditionExpression(expression).Evaluate(testValues), expression);
}
void AssertParseFailure(string expression)
{
Assert.Throws(typeof(InvalidDataException), () => new BooleanExpression(expression).Evaluate(testValues), expression);
Assert.Throws(typeof(InvalidDataException), () => new ConditionExpression(expression).Evaluate(testValues), expression);
}
[TestCase(TestName = "AND operation")]

View File

@@ -55,7 +55,7 @@
<Compile Include="OpenRA.Mods.Common\ShapeTest.cs" />
<Compile Include="OpenRA.Game\OrderTest.cs" />
<Compile Include="OpenRA.Game\PlatformTest.cs" />
<Compile Include="OpenRA.Game\BooleanExpressionTest.cs" />
<Compile Include="OpenRA.Game\ConditionExpressionTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">