using System; using System.Collections.Generic; using System.Text; using UnitTestSharp; using Sunweaver.Commands.Abstracts; namespace Sunweaver.UnitTests.Commands.Abstracts { public class BinaryBooleanOperationTests : TestFixture { class BinaryBooleanOperationTester : BinaryBooleanLogic { public bool A = false, B = false; public override void Operation(bool a, bool b) { A = a; B = b; } public override void CompileOperation( System.Reflection.Emit.ILGenerator il, Sunweaver.DataPrototypes.Locals locals) { //Pass } } public override void TestSetup() { VM = new Sunweaver.DataPrototypes.VirtualMachine(); } BinaryBooleanOperationTester bp = new BinaryBooleanOperationTester(); Sunweaver.DataPrototypes.VirtualMachine VM; public void DecreasesStackDepthBy2() { CheckEqual((long)0, VM.BoolStack.Count()); VM.BoolStack.Push(false); VM.BoolStack.Push(false); VM.BoolStack.Push(false); bp.Implementation(VM); CheckEqual((long)1, VM.BoolStack.Count()); } public void FizzlesWhenEmpty() { CheckEqual((long)0, VM.BoolStack.Count()); bp.A = false; bp.B = false; bp.Implementation(VM); CheckEqual((long)0, VM.BoolStack.Count()); CheckFalse( bp.A); CheckFalse( bp.B); } public void FizzlesWhenAlmostEmpty() { CheckEqual((long)0, VM.BoolStack.Count()); VM.BoolStack.Push(false); bp.A = true; bp.B = true; bp.Implementation(VM); CheckEqual((long)1, VM.BoolStack.Count()); CheckFalse( VM.BoolStack.Pop()); CheckTrue( bp.A); CheckTrue( bp.B); } public void PullsStackValuesInRightOrderAndCorrectly() { CheckEqual((long)0, VM.BoolStack.Count()); VM.BoolStack.Push(false); VM.BoolStack.Push(true); bp.Implementation(VM); CheckFalse( bp.A); CheckTrue( bp.B); } } }