Example #1
0
    def test_correct_syntax_without_return_value_1(self):
        text = "another_function[]"
        name, arguments, return_value = parse_function(text)

        self.assertEqual(name, "another_function")
        self.assertEqual(arguments, None)
        self.assertEqual(return_value, None)
Example #2
0
    def test_correct_syntax_with_two_return_values(self):

        text = "another_function[] => [E :bool, F:place]"
        name, arguments, return_value = parse_function(text)

        self.assertEqual(name, "another_function")
        self.assertEqual(arguments, None)
        self.assertEqual(return_value, {'E': 'bool', 'F': 'place'})
Example #3
0
    def test_correct_syntax_without_return_value_3(self):

        text = "another_function[A:place, B :pose]"
        name, arguments, return_value = parse_function(text)

        self.assertEqual(name, "another_function")
        self.assertEqual(arguments, {'A': 'place', 'B': 'pose'})
        self.assertEqual(return_value, None)
Example #4
0
    def test_correct_syntax_using_two_argument(self):

        text = "another_function[A:place, B :pose]=>[E :bool]"
        name, arguments, return_value = parse_function(text)

        self.assertEqual(name, "another_function")
        self.assertEqual(arguments, {'A': 'place', 'B': 'pose'})
        self.assertEqual(return_value, {'E': 'bool'})
Example #5
0
    def test_correct_syntax_using_without_arguments_2(self):

        text = "a_function []=>[E :bool]"
        name, arguments, return_value = parse_function(text)

        self.assertEqual(name, "a_function")
        self.assertEqual(arguments, None)
        self.assertEqual(return_value, {'E': 'bool'})
Example #6
0
    def _execute_test(test_name, text):

        print("\n")
        print(test_name)
        print(" + original: ", text)
        name, arguments, return_value = parse_function(text)
        print(" + Result")
        print("    + name: ", name)
        print("    + arguments: ", arguments)
        print("    + return value: ", return_value)
 def __init__(self, text):
     operation.print_parsed_function(text)
     self._operation = operation.parse_function(text)
     super().__init__(self._operation[0])
Example #8
0
    def test_wrong_syntax_return_value_without_parenthesis(self):

        with self.assertRaises(Exception):
            text = "another_function[] => E :bool"
            parse_function(text)
Example #9
0
    def test_wrong_syntax_return_values_only_parenthesis(self):

        with self.assertRaises(Exception):
            text = "another_function[] => []"
            parse_function(text)
Example #10
0
    def test_wrong_syntax_function_declaration_without_parenthesis(self):

        with self.assertRaises(Exception):
            text = "another_function => (E :bool)"
            parse_function(text)