Example #1
0
def test_maps():
    calc2 = Calculator()  # Initializer overload (props is optional)
    calc2.add(10)
    calc2.add(20)
    calc2.mul(2)

    assert len(calc2.operations_map.get("add")) == 2
    assert len(calc2.operations_map.get("mul")) == 1
    assert calc2.operations_map.get("add")[1].value == 30
Example #2
0
def test_callMethods():
    calc = Calculator()

    calc.add(10)
    assert calc.value == 10

    calc.mul(2)
    assert calc.value == 20

    calc.pow(5)
    assert calc.value == 20 ** 5

    calc.neg()
    assert calc.value == -3_200_000