summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2020-05-29 10:27:40 +0200
committerArmin Rigo <arigo@tunes.org>2020-05-29 10:27:40 +0200
commit82389a693860fa1add7ced57334f9b18c7f04d0e (patch)
tree3c4178318a7f2eef7345559b80f7b04eb630365a /testing
parentab1d6096f86f3364b78a19a67e6fd908acb57c1a (diff)
downloadcffi-82389a693860fa1add7ced57334f9b18c7f04d0e.tar.gz
#454
Second try with '# NUMBER' instead of '#line NUMBER', as gcc seems to output
Diffstat (limited to 'testing')
-rw-r--r--testing/cffi0/test_parsing.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
index 5f2d7ec..a5e4587 100644
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -199,6 +199,21 @@ def test_dont_remove_comment_in_line_directives():
some syntax error here
""")
+ #
+ assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
+ ffi = FFI(backend=FakeBackend())
+ e = py.test.raises(CDefError, ffi.cdef, """
+ \t # \t 8 \t "baz.c" \t
+
+ some syntax error here
+ """)
+ assert str(e.value) == "parse error\nbaz.c:9:14: before: syntax"
+ #
+ e = py.test.raises(CDefError, ffi.cdef, """
+ # 7 "foo//bar.c"
+
+ some syntax error here
+ """)
assert str(e.value) == "parse error\nfoo//bar.c:8:14: before: syntax"
def test_multiple_line_directives():
@@ -214,6 +229,18 @@ def test_multiple_line_directives():
extern int zz;
""")
assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
+ #
+ e = py.test.raises(CDefError, ffi.cdef,
+ """ # 5 "foo.c"
+ extern int xx;
+ # 6 "bar.c"
+ extern int yy;
+ # 7 "baz.c"
+ some syntax error here
+ # 8 "yadda.c"
+ extern int zz;
+ """)
+ assert str(e.value) == "parse error\nbaz.c:7:14: before: syntax"
def test_commented_line_directive():
ffi = FFI(backend=FakeBackend())
@@ -229,6 +256,20 @@ def test_commented_line_directive():
*/
some syntax error
""")
+ #
+ assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
+ e = py.test.raises(CDefError, ffi.cdef, """
+ /*
+ # 5 "foo.c"
+ */
+ void xx(void);
+
+ # 6 "bar.c"
+ /*
+ # 35 "foo.c"
+ */
+ some syntax error
+ """)
assert str(e.value) == "parse error\nbar.c:9:14: before: syntax"
def test_line_continuation_in_defines():