def test_function_parameter_type_mismatch(): try: code = ["def echo(msg):", " return 1", 'echo(1)', 'a = echo("Hi")'] analysis_code_list(code) except ParamTypeMismatchError: assert True else: assert False
def test_simple_import(): code = [ 'import os', ] try: analysis_code_list(code) except ImportError: assert True else: assert False
def test_simple_from_import(): code = [ 'from os.path import join', ] try: analysis_code_list(code) except ImportError: assert True else: assert False
def test_simple_from_import(): code = [ 'from os.path import join', ] try: analysis_code_list(code) except ImportError: assert True else: assert False
def test_simple_import(): code = [ 'import os', ] try: analysis_code_list(code) except ImportError: assert True else: assert False
def test_function_parameter_type_mismatch(): try: code = [ "def echo(msg):", " return 1", 'echo(1)', 'a = echo("Hi")' ] analysis_code_list(code) except ParamTypeMismatchError: assert True else: assert False
def test_number_le_op(): code = [ 'a = 10', 'a != 10', ] assert analysis_code_list(code) == """export a=10
def test_function_call_in_parameter(): code = [ "test1(echo('Hi'))", "test2(echo('Hi'))", "test3(echo('Hi'))", ] assert analysis_code_list(code) == """echo "Hi"
def test_function_return_type_anlyzer(): code = [ 'def echo(msg):', ' return 1', 'a = echo("Hi")' ] assert analysis_code_list(code) == """function echo() {
def test_complex_numeric_operation_with_function_call(): code = [ 'def a():', ' return 1', 'c = 3 - a()', ] assert analysis_code_list(code) == """function a() {
def test_simple_numeric_operation_with_function_call(): code = [ 'def a():', ' return 1', 'b = a() + 3', ] assert analysis_code_list(code) == """function a() {
def test_command(): code = [ 'from sherlock.cmd import ls', 'ls("-al")' ] assert analysis_code_list(code) == """if ! type "ls" &> /dev/null ; then
def test_number_le_op(): code = [ 'a = 10', 'a != 10', ] assert analysis_code_list(code) == """export a=10
def test_simple_numeric_operation_with_function_call(): code = [ 'def a():', ' return 1', 'b = a() + 3', ] assert analysis_code_list(code) == """function a() {
def test_complex_numeric_operation_with_function_call(): code = [ 'def a():', ' return 1', 'c = 3 - a()', ] assert analysis_code_list(code) == """function a() {
def test_function_call_in_parameter(): code = [ "test1(echo('Hi'))", "test2(echo('Hi'))", "test3(echo('Hi'))", ] assert analysis_code_list(code) == """echo "Hi"
def test_string_not_equal_op(): code = [ 'a = "10"', 'if a != "10":', ' pass' ] assert analysis_code_list(code) == """export a="10"
def test_string_is_op(): code = [ 'a = "10"', 'if a is "10":', ' pass' ] assert analysis_code_list(code) == """export a="10"
def test_simple_if_statement(): code = [ 'a = 10', 'if a == 10:', ' echo("Hi")', ] assert analysis_code_list(code) == """export a=10
def test_simple_if_statement(): code = [ 'a = 10', 'if a == 10:', ' echo("Hi")', ] assert analysis_code_list(code) == """export a=10
def test_simple_while_statement(): code = [ 'i = 0', 'while i < 5:', ' echo(i)', ' i += 1' ] assert analysis_code_list(code) == """export i=0
def test_list_parameter(): code = [ 'def test(a, b):', ' echo(a)', ' echo(b)', 'a = ["1", "2"]', 'b = 10', 'test(a, b)', ] assert analysis_code_list(code) == """function test() {
def test_complex_numeric_operation(): code = [ 'a = 2 + (3 - 4) * 6 / 2', ] assert analysis_code_list( code) == 'export a=$(( 2 + $(( $(( $(( 3 - 4 )) * 6 )) / 2 )) ))\n'
def test_simple_add_numbers_anlyzer(): code = [ 'a = 2 + 3', ] assert analysis_code_list(code) == 'export a=$(( 2 + 3 ))\n'
def test_function_return_type_anlyzer(): code = ['def echo(msg):', ' return 1', 'a = echo("Hi")'] assert analysis_code_list(code) == """function echo() {
def test_aug_assign_operation(): code = [ 'a = 1', 'a += 1', ] assert analysis_code_list(code) == """export a=1
def test_run_command_line_command(): code = [ 'git("commit", "-m", "Hello")', ] assert analysis_code_list(code) == 'git "commit" "-m" "Hello"\n'
def test_add_string_variable_and_number(): code = [ 'b = "Hello"', 'a = 2 + b', ] assert analysis_code_list(code) == """export b="Hello"
def test_string_is_op(): code = ['a = "10"', 'if a is "10":', ' pass'] assert analysis_code_list(code) == """export a="10"
def test_simple_add_string_and_number_anlyzer(): code = [ 'a = 2 + "Hello"', ] assert analysis_code_list(code) == 'export a=2"Hello"\n'
def test_print(): code = [ 'print("Hello World")', ] assert analysis_code_list(code) == 'echo "Hello World"\n'
def test_simple_for_statement(): code = ['for i in range(1, 5):', ' pass'] assert analysis_code_list(code) == """for i in $(seq 1 $(( 5 - 1 )))
def test_complex_numeric_operation(): code = [ 'a = 2 + (3 - 4) * 6 / 2', ] assert analysis_code_list(code) == 'export a=$(( 2 + $(( $(( $(( 3 - 4 )) * 6 )) / 2 )) ))\n'
def test_simple_add_string_and_number_anlyzer(): code = [ 'a = 2 + "Hello"', ] assert analysis_code_list(code) == 'export a=2"Hello"\n'
def test_range(): code = [ 'range(1, 2)', ] assert analysis_code_list(code) == '$(seq 1 $(( 2 - 1 )))\n'
def test_string_not_equal_op(): code = ['a = "10"', 'if a != "10":', ' pass'] assert analysis_code_list(code) == """export a="10"
def test_range(): code = [ 'range(1, 2)', ] assert analysis_code_list(code) == '$(seq 1 $(( 2 - 1 )))\n'
def test_command(): code = ['from sherlock.cmd import ls', 'ls("-al")'] assert analysis_code_list(code) == """if ! type "ls" &> /dev/null ; then
def test_simple_add_numbers_anlyzer(): code = [ 'a = 2 + 3', ] assert analysis_code_list(code) == 'export a=$(( 2 + 3 ))\n'
def test_aug_assign_operation(): code = [ 'a = 1', 'a += 1', ] assert analysis_code_list(code) == """export a=1
def test_simple_for_statement(): code = [ 'for i in range(1, 5):', ' pass' ] assert analysis_code_list(code) == """for i in $(seq 1 $(( 5 - 1 )))
def test_simple_while_statement(): code = ['i = 0', 'while i < 5:', ' echo(i)', ' i += 1'] assert analysis_code_list(code) == """export i=0
def test_run_command_line_command(): code = [ 'git("commit", "-m", "Hello")', ] assert analysis_code_list(code) == 'git "commit" "-m" "Hello"\n'
def test_print(): code = [ 'print("Hello World")', ] assert analysis_code_list(code) == 'echo "Hello World"\n'
def test_complex_add(): code = [ 'a = 2 + (3 + 4) + 6', ] assert analysis_code_list( code) == 'export a=$(( $(( 2 + $(( 3 + 4 )) )) + 6 ))\n'
def test_mix_list_assign(): code = [ 'a = ["1", "2", 1, 2]' ] assert analysis_code_list(code) == 'export a=("1" "2" 1 2)\n'
def test_add_string_variable_and_number(): code = [ 'b = "Hello"', 'a = 2 + b', ] assert analysis_code_list(code) == """export b="Hello"
def test_numeric_list_assign(): code = [ 'a = [1, 2, 3, 4]' ] assert analysis_code_list(code) == 'export a=(1 2 3 4)\n'
def test_complex_add(): code = [ 'a = 2 + (3 + 4) + 6', ] assert analysis_code_list(code) == 'export a=$(( $(( 2 + $(( 3 + 4 )) )) + 6 ))\n'