Skip to content

Commit

Permalink
Minor cleanup in test
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Feb 21, 2015
1 parent fbc222c commit c67c920
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/test_c_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ def parse_to_ast(src):
return _c_parser.parse(src)


class FuncDeclVisitor(c_ast.NodeVisitor):
def __init__(self):
self.stubs = []

def visit_FuncDecl(self, node):
gen = c_generator.CGenerator()
self.stubs.append(gen.visit(node))
class TestFunctionDeclGeneration(unittest.TestCase):
class _FuncDeclVisitor(c_ast.NodeVisitor):
def __init__(self):
self.stubs = []

def visit_FuncDecl(self, node):
gen = c_generator.CGenerator()
self.stubs.append(gen.visit(node))

class TestFunctionDeclGeneration(unittest.TestCase):
def test_partial_funcdecl_generation(self):
src = r'''
void noop(void);
void *something(void *thing);
int add(int x, int y);'''
ast = parse_to_ast(src)
v = FuncDeclVisitor()
v = TestFunctionDeclGeneration._FuncDeclVisitor()
v.visit(ast)
self.assertEqual(len(v.stubs), 3)
self.assertTrue(r'void noop(void)' in v.stubs)
Expand Down

0 comments on commit c67c920

Please sign in to comment.