Fix tests for dynamic ghc
[ghc.git] / testsuite / driver / testutil.py
1 # -----------------------------------------------------------------------------
2 # Utils
3
4 def id(a):
5 return a
6
7 def eq(x):
8 return lambda y,z=x: y == z
9
10 def neq(x):
11 return lambda y,z=x: y != z
12
13 def append(x,y):
14 return x + y
15
16 def concat(xs):
17 return reduce(append,xs,[])
18
19 def chop(s):
20 if s[len(s)-1:] == '\n':
21 return s[:len(s)-1]
22 else:
23 return s
24
25 def all(p,xs):
26 for x in xs:
27 if not p(x):
28 return False
29 return True
30
31 def elem(xs):
32 return lambda x: x in xs
33
34 def notElem(xs):
35 return lambda x: x not in xs
36
37 def version_to_ints(v):
38 return [ int(x) for x in v.split('.') ]
39
40 def version_lt(x, y):
41 return version_to_ints(x) < version_to_ints(y)
42
43 def version_le(x, y):
44 return version_to_ints(x) <= version_to_ints(y)
45
46 def version_gt(x, y):
47 return version_to_ints(x) > version_to_ints(y)
48
49 def version_ge(x, y):
50 return version_to_ints(x) >= version_to_ints(y)
51