summaryrefslogtreecommitdiffstats
path: root/lang/python/python-bidict/test.sh
blob: 3684614037d958a80533dcfdac2527007f7518bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

[ "$1" = python3-bidict ] || exit 0

python3 - <<'EOF'
from bidict import bidict

# Basic creation and lookup
b = bidict({'a': 1, 'b': 2, 'c': 3})
assert b['a'] == 1
assert b.inverse[1] == 'a'
assert b.inverse[2] == 'b'

# Put and update
b['d'] = 4
assert b['d'] == 4
assert b.inverse[4] == 'd'

# Delete
del b['d']
assert 'd' not in b
assert 4 not in b.inverse

# Inverse of inverse is the original
assert b.inverse.inverse is b

# len
assert len(b) == 3

print("python-bidict OK")
EOF