summaryrefslogtreecommitdiff
path: root/lang/python/python-rpds-py/test.sh
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2023-10-14 02:14:10 +0800
committerTianling Shen <cnsztl@gmail.com>2023-11-30 12:57:27 +0800
commit06231ce8cbf82f39f93cc2fa216fc8aa3cd3271c (patch)
tree6a98bf4fd0ec7f85e527d95aba45273a8830b65f /lang/python/python-rpds-py/test.sh
parent5bc25c0cdc9774279b7e99bfad6909e567a12eac (diff)
python-rpds-py: Add new package
From the README: Python bindings to the Rust rpds crate for persistent data structures. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'lang/python/python-rpds-py/test.sh')
-rw-r--r--lang/python/python-rpds-py/test.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/lang/python/python-rpds-py/test.sh b/lang/python/python-rpds-py/test.sh
new file mode 100644
index 000000000..d5dec8f5f
--- /dev/null
+++ b/lang/python/python-rpds-py/test.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+[ "$1" = python3-rpds-py ] || exit 0
+
+python3 - << 'EOF'
+
+from rpds import HashTrieMap, HashTrieSet, List
+
+m = HashTrieMap({"foo": "bar", "baz": "quux"})
+assert m.insert("spam", 37) == HashTrieMap({"foo": "bar", "baz": "quux", "spam": 37})
+assert m.remove("foo") == HashTrieMap({"baz": "quux"})
+
+s = HashTrieSet({"foo", "bar", "baz", "quux"})
+assert s.insert("spam") == HashTrieSet({"foo", "bar", "baz", "quux", "spam"})
+assert s.remove("foo") == HashTrieSet({"bar", "baz", "quux"})
+
+L = List([1, 3, 5])
+assert L.push_front(-1) == List([-1, 1, 3, 5])
+assert L.rest == List([3, 5])
+
+EOF