diff options
Diffstat (limited to 'tests/analysis')
-rw-r--r-- | tests/analysis/type.py | 17 |
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)) |