Commits

Andrey Lesnikov committed f3f9584

test*.py: Break long lines and renamed few vars

Comments (0)

Files changed (2)

test_generator.py

 # -*- coding: utf-8 -*-
 
+
 import unittest
 import ast
 import misc
                 ),
             ]
         )
-        g = generator.Generator()
-        g.table = table.Table()
-        g.table.generate_tables(ast_)
-        # print('\n' + my_pretty_print(g))
-        real_output = g.generate()
+        gen = generator.Generator()
+        gen.table = table.Table()
+        gen.table.generate_tables(ast_)
+        # print('\n' + my_pretty_print(gen))
+        real_output = gen.generate()
         expected_output = (
             '// import: stdio\n'
             '// import: ogre3d\n'
                 ),
             ]
         )
-        g = generator.Generator()
-        g.table = table.Table()
-        g.table.generate_tables(ast_)
-        # print('\n' + my_pretty_print(g))
-        real_output = g.generate()
+        gen = generator.Generator()
+        gen.table = table.Table()
+        gen.table.generate_tables(ast_)
+        # print('\n' + my_pretty_print(gen))
+        real_output = gen.generate()
         expected_output = (
             '\n'
             'int f1(int a, int b);\n'

test_my_parser.py

 
     def test_empty_module(self):
         input_string = ''
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[],
         )
 
     def test_empty_import(self):
         input_string = 'import{}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             import_list=[],
             declaration_sequence=[],
 
     def test_simple_import(self):
         input_string = 'import{module1}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             import_list=['module1'],
             declaration_sequence=[],
 
     def test_simple_import_2(self):
         input_string = 'import{module1 module2}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             import_list=['module1', 'module2'],
             declaration_sequence=[],
 
     def test_simple_type_declaration(self):
         input_string = 'type MyInteger Integer'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeTypeDeclaration(
                 field2 Float
             }
         '''
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeTypeDeclaration(
 
     def test_type_alias(self):
         input_string = 'type MyInteger Integer'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeTypeDeclaration(
 
     def test_const_declaration(self):
         input_string = 'const importantIdentifier Integer = 10'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeConstDeclaration(
 
     def test_simple_func(self):
         input_string = 'func testfunc2() {}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeFunctionDeclaration(
 
     def test_simple_func_with_return_value(self):
         input_string = 'func testfunc2() -> Integer {}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeFunctionDeclaration(
 
     def test_simple_func_with_parameter(self):
         input_string = 'func testfunc(par ParType) {}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         interface = ast.NodeFunctionInterface(
             parameter_list=[
                 ast.NodeFormalParameter(
 
     def test_simple_func_with_2_parameters(self):
         input_string = 'func testfunc(par1 ParType, par2 ParType) {}'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         interface = ast.NodeFunctionInterface(
             parameter_list=[
                 ast.NodeFormalParameter(
 
     def test_func_body_2_empty_blocks(self):
         input_string = 'func fname() { {} {} }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body = [[], []]
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_func_call(self):
         input_string = 'func fname() { fname2() }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         funccall = ast.NodeFunctionCall(
             expression=ast.NodeIdentifier('fname2'),
 
     def test_var_declaration_without_initialization(self):
         input_string = 'func fname() { var testVar Integer }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         var = ast.NodeVariableDeclaration(
             name='testVar',
 
     def test_var_declaration_with_type_and_initialization(self):
         input_string = 'func fname() { var testVar Integer = 666 }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         var = ast.NodeVariableDeclaration(
             name='testVar',
 
     def test_var_declaration_with_initialization(self):
         input_string = 'func fname() { var testVar = 666 }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         var = ast.NodeVariableDeclaration(
             name='testVar',
 
     def test_var_declaration_with_ctor(self):
         input_string = 'func fname() { var p Parser() }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         var = ast.NodeVariableDeclaration(
             name='p',
 
     def test_var_declaration_with_init_2(self):
         input_string = 'func fname() { var v2 Int = plus(1, 2) }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         var = ast.NodeVariableDeclaration(
             name='v2',
 
     def test_var_declaration_with_ctor_and_arguments(self):
         input_string = 'func fname() { var p Parser(lexer, 1) }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeVariableDeclaration(
 
     def test_simple_if(self):
         input_string = 'func fname() { if 1 {} }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeIf(
 
     def test_simple_if_else(self):
         input_string = 'func fname() { if 1 {} else {} }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeIf(
 
     def test_nested_func_call_1(self):
         input_string = 'func fname() { a()() }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeFunctionCall(
 
     def test_simple_return_1(self):
         input_string = 'func fname() { return 1 }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeReturn(expression=ast.NodeNumber(1)),
 
     def test_simple_return_2(self):
         input_string = 'func fname() { return }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeReturn(expression=None),
 
     def test_simple_return_3(self):
         input_string = 'func fname() { return x() }'
-        real_ast = my_parser.make_parser().parse(input_string, lexer=my_parser.make_lexer())
+        real_ast = my_parser.make_parser().parse(
+                input_string, lexer=my_parser.make_lexer())
         expected_ast = copy.deepcopy(self._std_module)
         expected_ast.declaration_sequence[0].body.append(
             ast.NodeReturn(