def test_power_with_zero_raised_to_zero(self): calc.one_time_use("0.0 0.0 pow") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("0/-/ 0 pow") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("0 0/-/ pow") assert config.exit_flag == 1
def main(): arg_parser = argparse.ArgumentParser( description='Processes a rpn expression.') arg_parser.add_argument('--version', '-v', action='store_true', default=False, help='Prints the version number and exits.') arg_parser.add_argument( 'expression', nargs='*', help='Evaluates the expression in one time use format and exits.') args = arg_parser.parse_args() # if args.help: # print ("\033[34m" + docs + "\033[0m") # sys.exit() if args.version: from rpn import __version__ print(config.bcolors.OKGREEN + __version__ + config.bcolors.ENDC) else: #print("~ Nums: {}".format(args.expression)) if len(args.expression) > 0: # For one time use eval_string = '' for i in args.expression: eval_string += (i + " ") #print(eval_string) calc.one_time_use(eval_string) else: # For interactive use calc.interactive_use()
def test_greater_than(self, inp, out): assert calc.one_time_use(inp) == out
def test_rightshift_with_non_integers(self): calc.one_time_use("2 3 - 1 + 2 * 99 / 2 >>") # equals to "0.0 2 >>" assert config.exit_flag == 1
def test_divide_by_zero(self): calc.one_time_use("2 0 /") assert config.exit_flag == 1
def test_repeat(self, inp, out): assert calc.one_time_use(inp) == out
def test_nhs(self, inp, out): # config.dEG=1 assert calc.one_time_use(inp) == out
def test_multiply(self, inp, out): assert calc.one_time_use(inp) == out
def test_sqrt_for_negatives(self): calc.one_time_use("2/-/ sqrt") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("3.3/-/ sqrt") assert config.exit_flag == 1
def test_log_to_the_base_one(self): calc.one_time_use("1.0 1.0 log") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("3 1 log") assert config.exit_flag == 1
def test_log_negtive(self): calc.one_time_use("4/-/ 2 log") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("4 2/-/ log") assert config.exit_flag == 1
def test_mod_by_zero(self): calc.one_time_use("4.7 0 %") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("0/-/ 0 %") assert config.exit_flag == 1
def test_power(self, inp, out): assert calc.one_time_use(inp) == out
def test_bool_xor(self, inp, out): assert calc.one_time_use(inp) == out
def test_bit_xor_with_non_integers(self): calc.one_time_use("1.0 1.0 ^") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("1 1.0 ^") assert config.exit_flag == 1
def test_minus(self, inp, out): assert calc.one_time_use(inp) == out
def test_asin_input_outside_range(self): calc.one_time_use("2 asin") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("3.3/-/ asin") assert config.exit_flag == 1
def test_log_zero(self): calc.one_time_use("0 2.3 log") assert config.exit_flag == 1
def test_fact_of_floats_and_negative_integers(self): calc.one_time_use("2/-/ fact") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("3.3 fact") assert config.exit_flag == 1
def test_log_non_positive(self): calc.one_time_use("4/-/ ln") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("0 ln") assert config.exit_flag == 1
def test_hnl_negative_and_floats(self): calc.one_time_use("2/-/ hnl") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("2.2 hnl") assert config.exit_flag == 1
def test_increment(self, inp, out): assert calc.one_time_use(inp) == out
def test_nhs_negative_and_floats(self): calc.one_time_use("2/-/ nhs") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("2.2 nhs") assert config.exit_flag == 1
def test_bit_not(self, inp, out): assert calc.one_time_use(inp) == out
def test_divide(self, inp, out): assert calc.one_time_use(inp) == out
def test_bit_not_floats(self): calc.one_time_use("4.2/-/ ~") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("0.2 ~") assert config.exit_flag == 1
def test_rightshift(self, inp, out): assert calc.one_time_use(inp) == out
def test_sinh_overflow(self): calc.one_time_use("2300.2 sinh") assert config.exit_flag == 1 config.exit_flag = 0 calc.one_time_use("3000/-/ sinh") assert config.exit_flag == 1
def test_rightshift_with_negative_second_operand(self): calc.one_time_use("1/-/ 2/-/ >>") assert config.exit_flag == 1
def test_acos(self, inp, out): config.dEG, config.rAD = 1, 0 assert calc.one_time_use(inp) == out config.dEG, config.rAD = 0, 1