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
|
#!/bin/sh
cd "$ADTTMP"
cat > test.py << EOF
#!/usr/bin/python3
from toposort import toposort, toposort_flatten
data = {2: {11},
9: {11, 8, 10},
10: {11, 3},
11: {7, 5},
8: {7, 3}}
simple = [{3, 5, 7}, {8, 11}, {2, 10}, {9}]
flatten = [3, 5, 7, 8, 11, 2, 10, 9]
try:
assert(list(toposort(data)) == simple)
except AssertionError:
raise AssertionError('toposort failed')
try:
assert(list(toposort_flatten(data)) == flatten)
except AssertionError:
raise AssertionError('toposort_flatten failed')
EOF
python3 test.py
|