summaryrefslogtreecommitdiff
path: root/tests/test_c_lexer.py
diff options
context:
space:
mode:
authorJordy Ruiz <56157703+jordr@users.noreply.github.com>2023-01-08 12:14:46 +0100
committerGitHub <noreply@github.com>2023-01-08 03:14:46 -0800
commit4e16079578377c215c7c387eaa2948252e54b108 (patch)
treefc6b11d9134db1731c88670067a9f974d672ec2d /tests/test_c_lexer.py
parent5382e3119b84eabcb2369f70978e1b803cbd185a (diff)
downloadpycparser-4e16079578377c215c7c387eaa2948252e54b108.tar.gz
Feature/add pragma support (#487)
* Support _Pragma, a C99 alternative to #pragma See https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html * Test cases for _Pragma * Add explanatory comment for _PRAGMA and PPPRAGMA
Diffstat (limited to 'tests/test_c_lexer.py')
-rw-r--r--tests/test_c_lexer.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/test_c_lexer.py b/tests/test_c_lexer.py
index 03fd838..2975b80 100644
--- a/tests/test_c_lexer.py
+++ b/tests/test_c_lexer.py
@@ -357,6 +357,7 @@ class TestCLexerNoErrors(unittest.TestCase):
#pragma "string"
#pragma somestring="some_other_string"
#pragma id 124124 and numbers 0235495
+ _Pragma("something else")
59
'''
# Check that pragmas are tokenized, including trailing string
@@ -389,9 +390,19 @@ class TestCLexerNoErrors(unittest.TestCase):
tb = self.clex.token()
self.assertEqual(tb.type, 'PPPRAGMASTR')
- t6 = self.clex.token()
- self.assertEqual(t6.type, 'INT_CONST_DEC')
- self.assertEqual(t6.lineno, 12)
+ t6a = self.clex.token()
+ t6l = self.clex.token()
+ t6b = self.clex.token()
+ t6r = self.clex.token()
+ self.assertEqual(t6a.type, '_PRAGMA')
+ self.assertEqual(t6l.type, 'LPAREN')
+ self.assertEqual(t6b.type, 'STRING_LITERAL')
+ self.assertEqual(t6b.value, '"something else"')
+ self.assertEqual(t6r.type, 'RPAREN')
+
+ t7 = self.clex.token()
+ self.assertEqual(t7.type, 'INT_CONST_DEC')
+ self.assertEqual(t7.lineno, 13)