diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-07-17 21:20:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-17 21:20:59 (GMT) |
commit | 941ac1e19df176b68537f3d952a70f0e52659bf6 (patch) | |
tree | 0fcd7781973dce9cb1054d6e3591d0defc4e35f4 /Lib/test/test_clinic.py | |
parent | 2eef81e05ece14796e8e922ecac8e572a6e6d5b0 (diff) | |
download | cpython-941ac1e19df176b68537f3d952a70f0e52659bf6.zip cpython-941ac1e19df176b68537f3d952a70f0e52659bf6.tar.gz cpython-941ac1e19df176b68537f3d952a70f0e52659bf6.tar.bz2 |
[3.12] gh-106368: Increase Argument Clinic test coverage for cpp.Monitor (GH-106833) (#106838)
(cherry picked from commit 22379c60ab8f8b49e75da9bd032a8722af50b409)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Diffstat (limited to 'Lib/test/test_clinic.py')
-rw-r--r-- | Lib/test/test_clinic.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py index b5744f7..e925ecc 100644 --- a/Lib/test/test_clinic.py +++ b/Lib/test/test_clinic.py @@ -200,6 +200,55 @@ class ClinicWholeFileTest(_ParserBase): """).lstrip() # Note, lstrip() because of the newline self.assertEqual(out, expected) + def test_cpp_monitor_fail_nested_block_comment(self): + raw = """ + /* start + /* nested + */ + */ + """ + msg = ( + 'Error in file "test.c" on line 2:\n' + 'Nested block comment!\n' + ) + out = self.expect_failure(raw) + self.assertEqual(out, msg) + + def test_cpp_monitor_fail_invalid_format_noarg(self): + raw = """ + #if + a() + #endif + """ + msg = ( + 'Error in file "test.c" on line 1:\n' + 'Invalid format for #if line: no argument!\n' + ) + out = self.expect_failure(raw) + self.assertEqual(out, msg) + + def test_cpp_monitor_fail_invalid_format_toomanyargs(self): + raw = """ + #ifdef A B + a() + #endif + """ + msg = ( + 'Error in file "test.c" on line 1:\n' + 'Invalid format for #ifdef line: should be exactly one argument!\n' + ) + out = self.expect_failure(raw) + self.assertEqual(out, msg) + + def test_cpp_monitor_fail_no_matching_if(self): + raw = '#else' + msg = ( + 'Error in file "test.c" on line 1:\n' + '#else without matching #if / #ifdef / #ifndef!\n' + ) + out = self.expect_failure(raw) + self.assertEqual(out, msg) + class ClinicGroupPermuterTest(TestCase): def _test(self, l, m, r, output): |