def test_while_statement(self, pseutopy): pseudo_str = """ while a <= b do: set a to 1 end while a < b: set a to 2 end while a < b do set a to 1 end """ python_str = """ while a <= b: a = 1 while a < b: a = 2 while a < b: a = 1 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_bool_op(self, pseutopy): pseudo_str = """ set myVar to true and false set myVar to false or true""" python_str = """ myVar = True and False myVar = False or True """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_dict(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to {1: 'Hello', 2: 'Hi'}, {2: True} set [myVar1, myVar2] to {1: 'Hello', 2: 'Hi'}, {2: True} """ python_str = """ myVar1, myVar2 = {1: 'Hello', 2: 'Hi'}, {2: True} [myVar1, myVar2] = {1: 'Hello', 2: 'Hi'}, {2: True} """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_none(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to None, None set [myVar1, myVar2] to None, None """ python_str = """ myVar1, myVar2 = None, None [myVar1, myVar2] = None, None """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_set(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to {1, 2, 3}, {True, False} set [myVar1, myVar2] to {1, 2, 3}, {True, False} """ python_str = """ myVar1, myVar2 = {1, 2, 3}, {True, False} [myVar1, myVar2] = {1, 2, 3}, {True, False} """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_list(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to [1, 2], [3, 4, 5] set [myVar1, myVar2] to [1, 2], [3, 4, 5] """ python_str = """ myVar1, myVar2 = [1, 2], [3, 4, 5] [myVar1, myVar2] = [1, 2], [3, 4, 5] """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_arith_expr(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to 1 + 2 - 3 % 8, 5 / 4 * 5 set [myVar1, myVar2] to 1 + 2 - 3 % 8, 5 / 4 * 5 """ python_str = """ myVar1, myVar2 = 1 + 2 - 3 % 8, 5 / 4 * 5 [myVar1, myVar2] = 1 + 2 - 3 % 8, 5 / 4 * 5 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_unary_value(self, pseutopy): pseudo_str = """ set myVar1, myVar2, myVar3 to (plus 1, minus 2, not False) set [myVar1, myVar2, myVar3] to plus 1, minus 2, not True """ python_str = """ myVar1, myVar2, myVar3 = +1, -2, not False [myVar1, myVar2, myVar3] = +1, -2, not True """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_identifier(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to a, b set [myVar1, myVar2] to a, b """ python_str = """ myVar1, myVar2 = a, b [myVar1, myVar2] = a, b """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_simple_value(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to 1, 2 set [myVar1, myVar2] to 1, 2 """ python_str = """ myVar1, myVar2 = 1, 2 [myVar1, myVar2] = 1, 2 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_comparison(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to 3 is lower than 4, 3 is lower or equal to 4 set [myVar1, myVar2] to 3 is greater than 4, 3 is greater or equal to 4 """ python_str = """ myVar1, myVar2 = 3 < 4, 3 <= 4 [myVar1, myVar2] = 3 > 4, 3 >= 4 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_bool_op(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to True and False, False or False set [myVar1, myVar2] to True and False, False or False """ python_str = """ myVar1, myVar2 = True and False, False or False [myVar1, myVar2] = True and False, False or False """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_chained_assignment_set_tuple(self, pseutopy): pseudo_str = """ set myVar1, myVar2 to (1, 2), (3, 4) set [myVar1, myVar2] to (1, 2), (3, 4) """ python_str = """ myVar1, myVar2 = (1, 2), (3, 4) [myVar1, myVar2] = (1, 2), (3, 4) """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_func_def_parameter_statement(self, pseutopy): pseudo_str = """ def foo with arg1 as parameter: set a to arg1 end """ python_str = """ def foo(arg1): a = arg1 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_for_tuple_statement(self, pseutopy): pseudo_str = """ for i in (1, 2, 5, 6): set a to i end """ python_str = """ for i in (1, 2, 5, 6): a = i """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_func_def_no_parameter_statement(self, pseutopy): pseudo_str = """ define function foo with no parameter: set a to 1 end """ python_str = """ def foo(): a = 1 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_for_range_statement(self, pseutopy): pseudo_str = """ for i in range(0, 10, 1) do: set a to i end """ python_str = """ for i in range(0, 10, 1): a = i """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_if_statement(self, pseutopy): pseudo_str = """ if True then set a to 1 end """ python_str = """ if True: a = 1 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_for_list_statement(self, pseutopy): pseudo_str = """ for i in [1, 2, 5, 6]: set a to i end """ python_str = """ for i in [1, 2, 5, 6]: a = i """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_set_set(self, pseutopy): pseudo_str = """ set myVar to {} set myVar to {1,} set myVar to {1, a} """ python_str = """ myVar = {} myVar = {1} myVar = {1, a} """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_set_tuple(self, pseutopy): pseudo_str = """ set myVar to () set myVar to (1,) set myVar to (1, 2, 3) """ python_str = """ myVar = () myVar = (1,) myVar = (1, 2, 3) """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_set_unary_value(self, pseutopy): pseudo_str = """ set myVar to plus 1 set myVar to minus 2 set myVar to not True """ python_str = """ myVar = +1 myVar = -2 myVar = not True """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_set_list(self, pseutopy): pseudo_str = """ set myVar to [] set myVar to [1,] set myVar to [1, 2, 3] """ python_str = """ myVar = [] myVar = [1] myVar = [1, 2, 3] """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_func_def_multiple_parameters_statement_2(self, pseutopy): pseudo_str = """ def foo with arg1, arg2 as parameters: set a to arg1 set b to arg2 end """ python_str = """ def foo(arg1, arg2): a = arg1 b = arg2 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_function_call_assignment_with_TestList(self, pseutopy): pseudo_str = """ set a to the result of range(10) set b to the result of range(0, 10) set c to the result of range(var1) set d to the result of range(var1, var2) """ python_str = """ a = range(10) b = range(0, 10) c = range(var1) d = range(var1, var2) """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_func_def_multiple_parameters_single_return_statement_( self, pseutopy): pseudo_str = """ def foo with arg1, arg2 as parameters: set a to arg1 + arg2 return a end """ python_str = """ def foo(arg1, arg2): a = arg1 + arg2 return a """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_set_dict(self, pseutopy): pseudo_str = """ set myVar to {} set myVar to {1: 1} set myVar to {1: a} set myVar to {1: "Hello", 2:"Hi"} """ python_str = """ myVar = {} myVar = {1: 1} myVar = {1: a} myVar = {1: "Hello", 2: "Hi"} """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_if_else_statement(self, pseutopy): pseudo_str = """ if a <= b then set a to 1 else: set a to 2 end """ python_str = """ if a <= b: a = 1 else: a = 2 """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_function_call_assignment_with_function(self, pseutopy): pseudo_str = """ set a to the result of call function foo with parameter 10 set b to the result of call function bar with parameters 0, 10 set c to the result of call function foobar with parameter myVar set d to the result of call function fizzbuzz with parameters var1, var2 set e to the result of call function fizbuz """ python_str = """ a = foo(10) b = bar(0, 10) c = foobar(myVar) d = fizzbuzz(var1, var2) e = fizbuz() """ assert check_ast(pseutopy, python_str, pseudo_str)
def test_simple_chained_assignment_set_arith_expr(self, pseutopy): pseudo_str = """ set myVar to 3 plus 4 set myVar to 3 minus 4 set myVar to 3 divided by 4 set myVar to 3 times 4 set myVar to 3 modulo 4 set myVar to 3 to the power of 4 set myVar to 1 plus 2 minus 3 times 4 divided by 5 modulo 6""" python_str = """ myVar = 3 + 4 myVar = 3 - 4 myVar = 3 / 4 myVar = 3 * 4 myVar = 3 % 4 myVar = 3 ** 4 myVar = 1 + 2 - 3 * 4 / 5 % 6 """ assert check_ast(pseutopy, python_str, pseudo_str)