Commits

Andrey Lesnikov  committed dd5b518

Added docstrings in test_*.py

  • Participants
  • Parent commits d41f793

Comments (0)

Files changed (4)

File test_generator.py

 # -*- coding: utf-8 -*-
 
 
+''' Test 'generator' module. '''
+
+
 import unittest
 import ast
 import misc
 
 
 class TestGenerator(unittest.TestCase):
+    ''' Test 'Generator' class. '''
 
     def test_1(self):
+        ''' Generate some code. '''
         ast_ = ast.NodeModule(
             import_list=['stdio', 'ogre3d'],
             declaration_sequence=[
         misc.assert_equal(self, expected_output, real_output)
 
     def test_2(self):
+        ''' Generate some simple code. '''
         ast_ = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeFunctionDeclaration(

File test_misc.py

 # -*- coding: utf-8 -*-
 
 
+''' Test 'misc' module. '''
+
+
 import unittest
 import misc
 
 
 class TestDiff(unittest.TestCase):
+    ''' Test misc.diff function. '''
 
     def test_1(self):
+        ''' Diff two lines. '''
         pass
 
 class TestPrettyPrinter(unittest.TestCase):
+    ''' Test misc.pretty_print function. '''
 
     def test_none(self):
+        ''' Print None. '''
         input_data = None
         expected_output = '<None>'
         real_output = misc.pretty_print(input_data)
         self.assertEqual(expected_output, real_output)
 
     def test_empty_list(self):
+        ''' Print empty list. '''
         input_data = []
         expected_output = '[]'
         real_output = misc.pretty_print(input_data)
         self.assertEqual(expected_output, real_output)
         
     def test_empty_map(self):
+        ''' Print empty map. '''
         input_data = {}
         expected_output = '{\n}'
         real_output = misc.pretty_print(input_data)

File test_my_parser.py

 # -*- coding: utf-8 -*-
 
+
+''' Test my_parser module. '''
+
+
 import unittest
 import ast
 import misc
 import my_parser
 
 class TestParser(unittest.TestCase):
+    ''' Test my_parser.make_parser() function. '''
 
     # TODO: Rename
     _std_module = ast.NodeModule(
     )
 
     def test_empty_module(self):
+        ''' Parse empty string. '''
         input_string = ''
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_empty_import(self):
+        ''' Parse empty import statement. '''
         input_string = 'import{}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_import(self):
+        ''' Parse import statement. '''
         input_string = 'import{module1}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_import_2(self):
+        ''' Parse import statement with two modules. '''
         input_string = 'import{module1 module2}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_type_declaration(self):
+        ''' Parse type simple declaration. '''
         input_string = 'type MyInteger Integer'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_struct_type_declaration(self):
+        ''' Some test :) '''
         input_string = '''
             type MyStruct struct {
                 field1 Int
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_type_alias(self):
+        ''' Some test :) '''
         input_string = 'type MyInteger Integer'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_const_declaration(self):
+        ''' Some test :) '''
         input_string = 'const importantIdentifier Integer = 10'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_func(self):
+        ''' Some test :) '''
         input_string = 'func testfunc2() {}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_func_with_return_value(self):
+        ''' Some test :) '''
         input_string = 'func testfunc2() -> Integer {}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_func_with_parameter(self):
+        ''' Some test :) '''
         input_string = 'func testfunc(par ParType) {}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_func_with_2_parameters(self):
+        ''' Some test :) '''
         input_string = 'func testfunc(par1 ParType, par2 ParType) {}'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_func_body_2_empty_blocks(self):
+        ''' Some test :) '''
         input_string = 'func fname() { {} {} }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_func_call(self):
+        ''' Some test :) '''
         input_string = 'func fname() { fname2() }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_var_declaration_without_initialization(self):
+        ''' Some test :) '''
         input_string = 'func fname() { var testVar Integer }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_var_declaration_with_type_and_initialization(self):
+        ''' Some test :) '''
         input_string = 'func fname() { var testVar Integer = 666 }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_var_declaration_with_initialization(self):
+        ''' Some test :) '''
         input_string = 'func fname() { var testVar = 666 }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_var_declaration_with_ctor(self):
+        ''' Some test :) '''
         input_string = 'func fname() { var p Parser() }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_var_declaration_with_init_2(self):
+        ''' Some test :) '''
         input_string = 'func fname() { var v2 Int = plus(1, 2) }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_var_declaration_with_ctor_and_arguments(self):
+        ''' Some test :) '''
         input_string = 'func fname() { var p Parser(lexer, 1) }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_if(self):
+        ''' Some test :) '''
         input_string = 'func fname() { if 1 {} }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_if_else(self):
+        ''' Some test :) '''
         input_string = 'func fname() { if 1 {} else {} }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_nested_func_call_1(self):
+        ''' Some test :) '''
         input_string = 'func fname() { a()() }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_return_1(self):
+        ''' Some test :) '''
         input_string = 'func fname() { return 1 }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_return_2(self):
+        ''' Some test :) '''
         input_string = 'func fname() { return }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())
         misc.assert_equal(self, expected_ast, real_ast)
 
     def test_simple_return_3(self):
+        ''' Some test :) '''
         input_string = 'func fname() { return x() }'
         real_ast = my_parser.make_parser().parse(
                 input_string, lexer=my_parser.make_lexer())

File test_table.py

 
 
 class TestTable(unittest.TestCase):
+    ''' Test 'Table' class. '''
 
     def test_1(self):
+        ''' Just generate some tables. '''
         ast_ = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeFunctionDeclaration(
         # print('\n' + my_pretty_print(t))
 
     def test_2(self):
+        ''' bla bla bla. '''
         ast_ = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeFunctionDeclaration(
         misc.assert_equal(self, expected_output, real_output)
 
     def test_if(self):
+        ''' Test IF. '''
         ast_ = ast.NodeModule(
             declaration_sequence=[
                 ast.NodeFunctionDeclaration(