Author: Armin Rigo <[email protected]>
Branch: release-pypy2.7-5.x
Changeset: r91494:0ec86a2b43ab
Date: 2017-06-02 15:30 +0200
http://bitbucket.org/pypy/pypy/changeset/0ec86a2b43ab/
Log: I think this test needs to change too (from 'hg diff -r 486d919c0b87
-r 93fa52b7eed3 testing/' inside cffi)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
@@ -229,13 +229,27 @@
# this checks that we get a sensible error if we try "int foo(...);"
ffi = FFI()
e = py.test.raises(CDefError, ffi.cdef, "int foo(...);")
- assert str(e.value) == \
- "foo: a function with only '(...)' as argument is not correct C"
+ assert str(e.value) == (
+ "<cdef source string>:1: foo: a function with only '(...)' "
+ "as argument is not correct C")
def test_parse_error():
ffi = FFI()
e = py.test.raises(CDefError, ffi.cdef, " x y z ")
- assert re.match(r'cannot parse "x y z"\n:\d+:', str(e.value))
+ assert str(e.value).startswith(
+ 'cannot parse "x y z"\n<cdef source string>:1:')
+ e = py.test.raises(CDefError, ffi.cdef, "\n\n\n x y z ")
+ assert str(e.value).startswith(
+ 'cannot parse "x y z"\n<cdef source string>:4:')
+
+def test_error_custom_lineno():
+ ffi = FFI()
+ e = py.test.raises(CDefError, ffi.cdef, """
+# 42 "foobar"
+
+ a b c d
+ """)
+ assert str(e.value).startswith('parse error\nfoobar:43:')
def test_cannot_declare_enum_later():
ffi = FFI()
@@ -279,7 +293,8 @@
def test_unknown_argument_type():
ffi = FFI()
e = py.test.raises(CDefError, ffi.cdef, "void f(foobarbazzz);")
- assert str(e.value) == ("f arg 1: unknown type 'foobarbazzz' (if you meant"
+ assert str(e.value) == ("<cdef source string>:1: f arg 1:"
+ " unknown type 'foobarbazzz' (if you meant"
" to use the old C syntax of giving untyped"
" arguments, it is not supported)")
@@ -437,3 +452,9 @@
ffi._parser._declarations['extern_python foobar'] !=
ffi._parser._declarations['function bok'] ==
ffi._parser._declarations['extern_python bzrrr'])
+
+def test_error_invalid_syntax_for_cdef():
+ ffi = FFI()
+ e = py.test.raises(CDefError, ffi.cdef, 'void foo(void) {}')
+ assert str(e.value) == ('<cdef source string>:1: unexpected <FuncDef>: '
+ 'this construct is valid C but not valid in
cdef()')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit