Mercurial > public > mercurial-scm > hg-stable
diff tests/test-lrucachedict.py @ 39587:8f2c0d1b454c
util: update lrucachedict order during get()
get() should have the same semantics as __getitem__ for item
retrieval.
Differential Revision: https://phab.mercurial-scm.org/D4506
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 07 Sep 2018 10:18:20 -0700 |
parents | f296c0b366c8 |
children | 0c638ff69f5c |
line wrap: on
line diff
--- a/tests/test-lrucachedict.py Thu Sep 06 18:04:27 2018 -0700 +++ b/tests/test-lrucachedict.py Fri Sep 07 10:18:20 2018 -0700 @@ -67,6 +67,18 @@ for key in ('a', 'b'): self.assertIn(key, d) + def testget(self): + d = util.lrucachedict(4) + d['a'] = 'va' + d['b'] = 'vb' + d['c'] = 'vc' + + self.assertIsNone(d.get('missing')) + self.assertEqual(list(d), ['c', 'b', 'a']) + + self.assertEqual(d.get('a'), 'va') + self.assertEqual(list(d), ['a', 'c', 'b']) + def testcopypartial(self): d = util.lrucachedict(4) d.insert('a', 'va', cost=4)