Skip to content

Commit

Permalink
Update label test to check the structure of the AST
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Tiraboschi committed Jan 12, 2025
1 parent 6e4322d commit eca7688
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test_c_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2489,17 +2489,20 @@ def test_samescope_reuse_name(self):
'''
self.assertRaises(ParseError, self.parse, s2)

class TestCParser_labels(TestCParser_base):
""" Test issues related to the labels.
"""
def test_label_empty_statement(self):
# Labels with empty statements and no semicolon should be parsed correctly
s1 = r'''
int main() {
label:
int i = 0;
label0: i++;
label1:
}
'''
self.assertIsInstance(self.parse(s1), FileAST)
s1_ast : FileAST = self.parse(s1)
self.assertIsInstance(s1_ast.ext[0].body.block_items[1], Label)
self.assertIsInstance(s1_ast.ext[0].body.block_items[1].stmt, UnaryOp)
self.assertIsInstance(s1_ast.ext[0].body.block_items[2], Label)
self.assertIsInstance(s1_ast.ext[0].body.block_items[2].stmt, EmptyStatement)

if __name__ == '__main__':
#~ suite = unittest.TestLoader().loadTestsFromNames(
Expand Down

0 comments on commit eca7688

Please sign in to comment.