public void TheGtCommandLeavesResult0WhenValue1IsLessThanValue2() { _stack.PushValue(1); _stack.PushValue(2); _stack.Gt(); _stack.PopValue().Should().Be(0); }
bool RunScriptCommand(IProgramCounter programCounter, IVariableManager localVariables) { if (programCounter.Eof) { throw new Exception($"Unexpected end of script found in '{programCounter.GetScriptName()}'"); } var command = programCounter.GetCommand(); switch ((ScriptToken)command) { case ScriptToken.PushIntValue: _stack.PushValue(programCounter.GetInteger()); break; case ScriptToken.PushStringValue: _stack.PushValue(programCounter.GetNullTerminatedString()); break; case ScriptToken.PushGlobalVariable: // 4 PushGlobalVariableOnToTheStack(programCounter); break; case ScriptToken.PopGlobalVariable: // 5 SetGlobalVariableToBottomValueOfStack(programCounter); break; case ScriptToken.Jfalse: // 6 MoveScriptPointerIfStackValueIsZero(programCounter); break; case ScriptToken.Jtrue: // 7 MoveScriptPointerIfStackValueIsNotZero(programCounter); break; case ScriptToken.Jall: // 8 MoveScriptPointerAlways(programCounter); break; case ScriptToken.Add: // 9 _stack.Add(); break; case ScriptToken.Subtract: // 10 _stack.Subtract(); break; case ScriptToken.Multiply: // 11 _stack.Multiply(); break; case ScriptToken.Divide: // 12 _stack.Divide(); break; case ScriptToken.Negate: // 13 _stack.Negate(); break; case ScriptToken.LogicalNot: // 14 _stack.LogicalNot(); break; case ScriptToken.Lt: // 15 _stack.Lt(); break; case ScriptToken.Gt: // 16 _stack.Gt(); break; case ScriptToken.Lte: // 17 _stack.Lte(); break; case ScriptToken.Gte: // 18 _stack.Gte(); break; case ScriptToken.VariableEquals: // 19 _stack.VariableEquals(); break; case ScriptToken.LogicalAnd: // 20 _stack.LogicalAnd(); break; case ScriptToken.LogicalOr: // 21 _stack.LogicalOr(); break; case ScriptToken.CallFnRoutine: // 22 ProcessFnRoutine(programCounter, localVariables); break; case ScriptToken.DropStackValue: // 23 return(_stack.PopValue() == 0); case ScriptToken.EndScript: // 24 return(false); case ScriptToken.DropSkipPauseNotZero: // 25 return(ProcessDropSkipPauseNotZero(programCounter)); case ScriptToken.PauseScript: // 26 return(false); case ScriptToken.PushLocalVariable: // 27 PushLocalVariableOnToTheStack(programCounter, localVariables); break; case ScriptToken.PopLocalVariable: // 28 SetLocalVariableToBottomValueOfStack(programCounter, localVariables); break; default: throw new InvalidOperationException($"Invalid Script Command {command}"); } return(true); }