+ def test_loc_set_hash_intern(self):
+ # type: () -> None
+ # hashes should match all other collections.abc.Set types, which are
+ # supposed to match frozenset but don't until Python 3.11 because of a
+ # bug fixed in:
+ # https://github.com/python/cpython/commit/c878f5d81772dc6f718d6608c78baa4be9a4f176
+ a = LocSet([])
+ self.assertEqual(hash(a), hash(OFSet()))
+ starts = 0, 1, 0, 1, 2
+ GPR = LocKind.GPR
+ expected = OFSet(Loc(kind=GPR, start=i, reg_len=1) for i in starts)
+ b = LocSet(expected)
+ c = LocSet(Loc(kind=GPR, start=i, reg_len=1) for i in starts)
+ d = LocSet(Loc(kind=GPR, start=i, reg_len=1) for i in starts)
+ # hashes should be equal to OFSet's hash
+ self.assertEqual(hash(b), hash(expected))
+ self.assertEqual(hash(c), hash(expected))
+ self.assertEqual(hash(d), hash(expected))
+ # they should intern to the same object
+ self.assertIs(b, d)
+ self.assertIs(c, d)
+