'Test deserialization of intrinsic'

def test_deserialization(self):

    def defn(context, x):
        def codegen(context, builder, signature, args):
            return args[0]
        return (x(x), codegen)
    memo = _Intrinsic._memo
    memo_size = len(memo)
    original = _Intrinsic('foo', defn)
    self.assertIs(original._defn, defn)
    pickled = pickle.dumps(original)
    memo_size += 1
    self.assertEqual(memo_size, len(memo))
    del original
    memo_size -= 1
    self.assertEqual(memo_size, len(memo))
    rebuilt = pickle.loads(pickled)
    self.assertIsNot(rebuilt._defn, defn)
    second = pickle.loads(pickled)
    self.assertIs(rebuilt._defn, second._defn)
