File: Versions.hs

package info (click to toggle)
haskell-debian 3.64-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 364 kB
  • sloc: haskell: 3,226; ansic: 8; makefile: 3
file content (111 lines) | stat: -rw-r--r-- 3,494 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
module Test.Versions where

import Test.HUnit

import Debian.Version

-- * Implicit Values

implicit1 =
    TestCase (assertEqual "1.0 == 1.0-" EQ (compare (parseDebianVersion "1.0") (parseDebianVersion "1.0-")))

implicit2 =
    TestCase (assertEqual "1.0 == 1.0-0" EQ (compare (parseDebianVersion "1.0") (parseDebianVersion "1.0-0")))

implicit3 = 
    TestCase (assertEqual "1.0 == 0:1.0-0" EQ (compare (parseDebianVersion "1.0") (parseDebianVersion "0:1.0-0")))

implicit4 = 
    TestCase (assertEqual "1.0 == 1.0-" EQ (compare (parseDebianVersion "1.0") (parseDebianVersion "1.0-")))

implicit5 = 
    TestCase (assertEqual "apple = apple0" EQ (compare (parseDebianVersion "apple") (parseDebianVersion "apple0")))

implicit6 = 
    TestCase (assertEqual "apple = apple0-" EQ (compare (parseDebianVersion "apple") (parseDebianVersion "apple0-")))

implicit7 = 
    TestCase (assertEqual "apple = apple0-0" EQ (compare (parseDebianVersion "apple") (parseDebianVersion "apple0-0")))

-- * epoch, version, revision

epoch1 =
    TestCase (assertEqual "epoch 0:0" (Just 0) (epoch $ parseDebianVersion "0:0"))

epoch2 =
    TestCase (assertEqual "epoch 0" Nothing(epoch $ parseDebianVersion "0"))

epoch3 =
    TestCase (assertEqual "epoch 1:0" (Just 1) (epoch $ parseDebianVersion "1:0"))

version1 =
    TestCase (assertEqual "version apple" "apple" (version $ parseDebianVersion "apple"))

version2 =
    TestCase (assertEqual "version apple0" "apple0" (version $ parseDebianVersion "apple0"))

version3 =
    TestCase (assertEqual "version apple1" "apple1" (version $ parseDebianVersion "apple1"))

revision1 =
    TestCase (assertEqual "revision 1.0" Nothing (revision $ parseDebianVersion "1.0"))

revision2 =
    TestCase (assertEqual "revision 1.0-" (Just "") (revision $ parseDebianVersion "1.0-"))

revision3 =
    TestCase (assertEqual "revision 1.0-0" (Just "0") (revision $ parseDebianVersion "1.0-0"))

revision4 =
    TestCase (assertEqual "revision 1.0-apple" (Just "apple") (revision $ parseDebianVersion "1.0-apple"))


-- * Ordering

compareV str1 str2 = compare (parseDebianVersion str1) (parseDebianVersion str2)

order1 =
    TestCase (assertEqual "1:1-1 > 0:1-1" GT (compareV "1:1-1" "0:1-1"))

order2 =
    TestCase (assertEqual "1-1-1 > 1-1" GT (compareV "1-1-1" "1-1"))

-- * Dashes in upstream version

dash1 =
    TestCase (assertEqual "version of upstream-version-revision" "upstream-version" (version (parseDebianVersion "upstream-version-revision")))

dash2 =
    TestCase (assertEqual "revision of upstream-version-revision" (Just "revision") (revision (parseDebianVersion "upstream-version-revision")))

-- * Insignificant Zero's

zero1 =
    TestCase (assertEqual "0.09 = 0.9" EQ (compareV "0.09" "0.9"))

-- * Tests

versionTests =
    [ TestLabel "implicit1" implicit1
    , TestLabel "implicit2" implicit2
    , TestLabel "implicit3" implicit3
    , TestLabel "implicit4" implicit4
    , TestLabel "implicit5" implicit5
    , TestLabel "implicit5" implicit6
    , TestLabel "implicit5" implicit7
    , TestLabel "epoch1" epoch1
    , TestLabel "epoch2" epoch2
    , TestLabel "epoch3" epoch3
    , TestLabel "version1" version1
    , TestLabel "version2" version2
    , TestLabel "version3" version3
    , TestLabel "revision1" revision1
    , TestLabel "revision2" revision2
    , TestLabel "revision3" revision3
    , TestLabel "revision4" revision4
    , TestLabel "order1" order1
    , TestLabel "order2" order2
    , dash1
    , dash2
    , zero1
    ]