Skip to content
Snippets Groups Projects
Commit 39dbe1d0 authored by pompolic's avatar pompolic
Browse files

Tests for HParseResult.make_HParsedToken()

parent dccd9af4
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,34 @@ class HParseResultCreation(unittest.TestCase):
#TODO: Mocking the read_member method might be needed
#TODO: MagicMock breaks self.token_type comparison
#TODO: mock read_AST_not_null() to return true
def test_make_HParsedToken(self):
gdbv_patcher = unittest.mock.patch('gdb.Value', autospec=True)
hpt_patcher = unittest.mock.patch('__main__.HParsedToken', autospec=True)
hpr_patcher = unittest.mock.patch.object(HParseResult, 'read_AST_not_null', return_value=True)
gdbv_patcher.start()
hpt_patcher.start()
hpr_patcher.start()
hpr = HParseResult(0xdeadbeef)
tok = hpr.make_HParsedToken()
hpr_patcher.stop()
hpt_patcher.stop()
gdbv_patcher.stop()
#TODO: what are the invariants we need to test here?
# e.g.: tok.address = hpr.ast.value
self.assertEqual(tok.address, hpr.ast)
def test_make_HParsedToken_if_no_ast(self):
gdbv_patcher = unittest.mock.patch('gdb.Value', autospec=True)
hpt_patcher = unittest.mock.patch('__main__.HParsedToken', autospec=True)
hpr_patcher = unittest.mock.patch.object(HParseResult, 'read_AST_not_null', return_value=False)
gdbv_patcher.start()
hpt_patcher.start()
hpr_patcher.start()
hpr = HParseResult(0xdeadbeef)
tok = hpr.make_HParsedToken()
hpr_patcher.stop()
hpt_patcher.stop()
gdbv_patcher.stop()
self.assertIsNone(tok)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment