Permalink
Browse files

AdventureSample - subtract expr

  • Loading branch information...
bobbymcr committed Apr 22, 2018
1 parent ffbe4dc commit 543f5376cbaa263049bf36f224a9f2a8a3df269a
@@ -301,6 +301,9 @@ public void Operator(string name, BasicExpression[] operands)
case "Add":
this.Value = this.Binary(this.generator.AddExpression, operands[0], operands[1]);
break;
case "Sub":
this.Value = this.Binary(this.generator.SubtractExpression, operands[0], operands[1]);
break;
default:
throw new NotSupportedException("Operator:" + name);
}
@@ -0,0 +1,48 @@
// <copyright file="SubtractExpressions.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace GWBas2CS.Test
{
using FluentAssertions;
using Xunit;
public sealed class SubtractExpressions
{
[Fact]
public void TwoNumericOperands()
{
const string Input = @"10 A=A-1";
const string Expected = @"*
private bool Main()
{
this.Init();
A_n = ((A_n) - (1));
return false;
}
*";
string actual = Test.Translate("MyProg", Input);
actual.Should().Match(Expected);
}
[Fact]
public void ThreeNumericOperands()
{
const string Input = @"10 A=A-B-2";
const string Expected = @"*
private bool Main()
{
this.Init();
A_n = (((A_n) - (B_n)) - (2));
return false;
}
*";
string actual = Test.Translate("MyProg", Input);
actual.Should().Match(Expected);
}
}
}

0 comments on commit 543f537

Please sign in to comment.