def calculateAndReturnAnsToken(operandStack, operatorStack): num2Token = st.popStack(operandStack) # Pop the second operand for calculation (FILO) num1Token = st.popStack(operandStack) # Pop the first operand for calculation (FILO) operator = st.popStack(operatorStack) # Pop the operator for calculation ans = ar.calculationBasedOnOperator(num1Token.num, num2Token.num, operator.symbol) # Get the calculated ans token = operandT.createOperandToken(sI.formatNumber(ans)) # Create the operand token based on calculated ans return token
def test_j_calculationBasedOnOperator_given_88point888_124point44_equal_expect_exception_raised( self): # calculationBasedOnOperator(num1, num2, operator) try: self.assertEqual( None, ar.calculationBasedOnOperator(88.888, 124.44, '=')) except Exception as e: print(e)
def test_i_calculationBasedOnOperator_given_88point888_124point44_divide_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(88.888 / 124.44, ar.calculationBasedOnOperator(88.888, 124.44, '/'))
def test_g_calculationBasedOnOperator_given_88point888_12point44_multiply_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(88.888 * 12.44, ar.calculationBasedOnOperator(88.888, 12.44, '*'))
def test_h_calculationBasedOnOperator_given_8_5_divide_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(8 / 5, ar.calculationBasedOnOperator(8, 5, '/'))
def test_f_calculationBasedOnOperator_given_55_55_multiply_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(55 * 55, ar.calculationBasedOnOperator(55, 55, '*'))
def test_e_calculationBasedOnOperator_given_88point888_12point44_minus_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(88.888 - 12.44, ar.calculationBasedOnOperator(88.888, 12.44, '-'))
def test_d_calculationBasedOnOperator_given_8point888_8point888_minus_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(8.888 - 8.888, ar.calculationBasedOnOperator(8.888, 8.888, '-'))
def test_c_calculationBasedOnOperator_given_56_66_minus_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(56 - 66, ar.calculationBasedOnOperator(56, 66, '-'))
def test_a_calculationBasedOnOperator_given_12_12_plus_expect_correct( self): # calculationBasedOnOperator(num1, num2, operator) self.assertEqual(12 + 12, ar.calculationBasedOnOperator(12, 12, '+'))