Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r731:26a7f61c80a6
Date: 2012-07-27 19:48 +0200
http://bitbucket.org/cffi/cffi/changeset/26a7f61c80a6/

Log:    In case of repeated values in enums, operations like str(), or the
        default casting when returning a value from a function call, will
        return arbitrarily the first declared value.

diff --git a/testing/backend_tests.py b/testing/backend_tests.py
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -1194,3 +1194,9 @@
         py.test.raises(TypeError, ffi.new, p)
         p = ffi.new(ffi.typeof("int *"), 42)
         assert p[0] == 42
+
+    def test_enum_with_non_injective_mapping(self):
+        ffi = FFI(backend=self.Backend())
+        ffi.cdef("enum e { AA=0, BB=0, CC=0, DD=0 };")
+        e = ffi.cast("enum e", 'CC')
+        assert str(e) == "AA"     # pick the first one arbitrarily
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to