public void JumpRelativeWithTest_Success(FlagTest test) { using (var fixture = new ExecuteFixture().DoNotHalt().RuntimeTiming(1, 5)) { fixture.With(c => c.Flags.Setup(GetFlagExpression(test)).Returns(GetPositiveValue(test))); SetupRelativeJump(fixture, OpCode.JumpRelative, test); } }
private static bool GetPositiveValue(FlagTest test) { switch (test) { case FlagTest.NotZero: case FlagTest.NotCarry: case FlagTest.ParityOdd: case FlagTest.Positive: return(false); case FlagTest.Zero: case FlagTest.Carry: case FlagTest.ParityEven: case FlagTest.Negative: return(true); default: throw new ArgumentOutOfRangeException(nameof(test), test, null); } }
private static Expression <Func <IFlagsRegister, bool> > GetFlagExpression(FlagTest test) { switch (test) { case FlagTest.NotZero: case FlagTest.Zero: return(f => f.Zero); case FlagTest.NotCarry: case FlagTest.Carry: return(f => f.Carry); case FlagTest.ParityOdd: case FlagTest.ParityEven: return(f => f.ParityOverflow); case FlagTest.Positive: case FlagTest.Negative: return(f => f.Sign); default: throw new ArgumentOutOfRangeException(nameof(test), test, null); } }