mirror of
https://github.com/openwrt/packages.git
synced 2026-05-31 15:02:01 +08:00
30535ff1a9
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>
32 lines
582 B
Bash
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
|