#!/bin/sh

cd "$ADTTMP"
cat > test.py << EOF
#!/usr/bin/python


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
python test.py
