def test_calculator_2(): calculator = Calculator(4) calculator.type(3) assert 3 == calculator.output() calculator.multiply() calculator.type(2) calculator.type(0) assert 60 == calculator.output()
def test_calculator_1(): calculator = Calculator(3) calculator.input(8) assert 8 == calculator.output() calculator.type(5) calculator.type(3) assert 53 == calculator.output() calculator.add() calculator.type(4) calculator.type(0) assert 93 == calculator.output() calculator.divide() calculator.type(3) assert 31 == calculator.output() calculator.multiply() calculator.type(2) assert 62 == calculator.output()
def test_calculator3(): calculator = Calculator(3) calculator.add() calculator.input(3) calculator.multiply() calculator.type(2) calculator.add() calculator.type(1) assert 7 == calculator.output()
def test_strategy_execute(): memory = Calculator(5) strategy = Strategy([ Action(memory.add), Action(partial(memory.type, digit=3)), Action(memory.deduct), Action(partial(memory.type, digit=4)), ]) strategy.execute(OperationsCounter()) assert 4 == memory.output()