[pypy-svn] r29689 - in pypy/dist/pypy/rpython/ootypesystem: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu Jul 6 17:40:13 CEST 2006


Author: antocuni
Date: Thu Jul  6 17:40:10 2006
New Revision: 29689

Modified:
   pypy/dist/pypy/rpython/ootypesystem/ootype.py
   pypy/dist/pypy/rpython/ootypesystem/test/test_ootype.py
Log:
(antocuni, arigo)

Make it explicit that Instance compares by reference.



Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py	Thu Jul  6 17:40:10 2006
@@ -55,6 +55,15 @@
 
         self._null = make_null_instance(self)
         self._class = _class(self)
+
+    def __eq__(self, other):
+        return self is other
+
+    def __ne__(self, other):
+        return self is not other
+
+    def __hash__(self):
+        return object.__hash__(self)
         
     def _defl(self):
         return self._null

Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_ootype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_ootype.py	Thu Jul  6 17:40:10 2006
@@ -391,3 +391,9 @@
     assert inst_up == inst_up2
     assert hash(inst_up) == hash(inst_up2)
 
+def test_instance_equality():
+    A = Instance("Foo", ROOT)
+    B = Instance("Foo", ROOT)
+    # Instance compares by reference
+    assert not A == B
+    assert A != B 



More information about the Pypy-commit mailing list