Files
Alexandru Ardelean 30535ff1a9 python-lru-dict: update to 1.4.1; add test.sh
Add PYPI_SOURCE_NAME:=lru_dict as the sdist tarball filename
uses underscores while PYPI_NAME uses hyphens.

Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
2026-04-17 13:46:59 +03:00

32 lines
582 B
Bash

#!/bin/sh
[ "$1" = python3-lru-dict ] || exit 0
python3 - << 'EOF'
from lru import LRU
cache = LRU(3)
cache["a"] = 1
cache["b"] = 2
cache["c"] = 3
assert len(cache) == 3
# Adding a 4th item evicts the least-recently-used entry ("a")
cache["d"] = 4
assert len(cache) == 3
assert "a" not in cache
assert "d" in cache
# Access "b" to make it recently used, then "c" becomes LRU
_ = cache["b"]
cache["e"] = 5
assert "b" in cache
assert "c" not in cache
# Test LRU capacity can be changed at runtime
cache.set_size(5)
assert cache.get_size() == 5
print("python3-lru-dict OK")
EOF