4/37
Part 1 of 6 · Two limitsLearn and do

Three invariants and five edge cases are your test plan

Invariants are facts that must hold after every operation. Say them, then check them in your tests:

  1. len(cache) <= capacity.
  2. The map and the order hold exactly the same keys.
  3. The order is by last use, oldest first.
Predict

A cache stores None for a key, and get(key) returns None. Hit or miss?

Pick an answer above to see the rest
Predict

lru_cache(maxsize=0) wraps square, and square(3) runs twice. How many hits?

Pick one to see what it prints.
Pick an answer above to see the rest