summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/analysis/type.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/analysis/type.py b/tests/analysis/type.py
index 5106cbc..b690a55 100644
--- a/tests/analysis/type.py
+++ b/tests/analysis/type.py
@@ -90,3 +90,20 @@ class TestDataType(ChrysalideTestCase):
self.assertEqual(str(tp), 'NS.TP')
self.assertEqual(tp.namespace, (ns, '.'))
+
+
+ def testTypeHash(self):
+ """Hash a user-defined type."""
+
+ class MyUserType(DataType):
+
+ def __init__(self, name):
+ super(MyUserType, self).__init__()
+ self._name = name
+
+ def _hash(self):
+ return hash(self._name)
+
+ tp = MyUserType('random')
+
+ self.assertEqual(tp.hash, hash('random') & ((1 << 32) - 1))