summaryrefslogtreecommitdiff
path: root/tests/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-02-20 00:26:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-02-20 00:26:09 (GMT)
commit66b8d57f0c054065894ab3dd0f1640594013e441 (patch)
treea31cb44088c67d6fe9ee7aa36c67261a6cbd14b4 /tests/analysis
parent9ac491cba6aa35959fa1ffdb9ce979060f5f6b26 (diff)
Compute a hash value for data types.
Diffstat (limited to 'tests/analysis')
-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))