Root/test/tsort

Source at commit bc27b094af74a7c6f8b71ceaa63d1ba80d067cbb created 9 years 4 months ago.
By werner, With a little help from m8cutils and abyss, we now have regression tests for the topological sort. "make test" or "make tests" invokes the regression tests, "make valgrind" runs them under valgrind's watchful eyes.
1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6fped "tsort: total order" <<EOF
7package "_"
8
9%tsort {
10    a b
11    a c
12    a d
13    b c
14    b d
15    c d
16}
17EOF
18expect <<EOF
19a
20b
21c
22d
23EOF
24
25#------------------------------------------------------------------------------
26
27fped "tsort: partial order change (1)" <<EOF
28package "_"
29
30%tsort {
31    a b
32    a c
33    a d
34    d b
35}
36EOF
37expect <<EOF
38a
39c
40d
41b
42EOF
43
44#------------------------------------------------------------------------------
45
46fped "tsort: partial order change (2)" <<EOF
47package "_"
48
49%tsort {
50    b c
51    c d
52    a b
53}
54EOF
55expect <<EOF
56a
57b
58c
59d
60EOF
61
62#------------------------------------------------------------------------------
63
64fped "tsort: old order differs from resolution order" <<EOF
65package "_"
66
67%tsort {
68    +a +b +c +d
69    a c
70    a b
71    a d
72}
73EOF
74expect <<EOF
75a
76b
77c
78d
79EOF
80
81#------------------------------------------------------------------------------
82
83fped "tsort: order change due to priority" <<EOF
84package "_"
85
86%tsort {
87    a b
88    a c 1
89    a d
90}
91EOF
92expect <<EOF
93a
94c
95b
96d
97EOF
98
99#------------------------------------------------------------------------------
100
101fped "tsort: priority accumulation without decay" <<EOF
102package "_"
103
104%tsort {
105    +a +b +c +d
106    a b 1
107    a d 1
108}
109EOF
110expect <<EOF
111a
112b
113d
114c
115EOF
116
117#------------------------------------------------------------------------------
118
119fped "tsort: priority accumulation with decay" <<EOF
120package "_"
121
122%tsort {
123    +a -b +c +d
124    a b 1
125    a d 1
126}
127EOF
128expect <<EOF
129a
130b
131c
132d
133EOF
134
135#------------------------------------------------------------------------------
136
137fped_fail "tsort: cycle" <<EOF
138package "_"
139
140%tsort {
141    a b
142    b a
143}
144EOF
145expect <<EOF
146cycle detected in partial order
147Aborted (core dumped)
148EOF
149
150# not entirely comfortable about the "Aborted (core dumped)". It's a system
151# message (from the shell) that may get mangled. Also, since few people keep
152# their cores these days, "(core dumped)" shouldn't really appear. Wonder why
153# it does. strace agrees that __WCOREFLAG is set ...
154
155###############################################################################
156

Archive Download this file

Branches:
master



interactive