File: Regression.hs

package info (click to toggle)
haskell-glob 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 192 kB
  • sloc: haskell: 1,193; makefile: 2
file content (132 lines) | stat: -rw-r--r-- 4,554 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
-- File created: 2008-10-15 20:21:41

module Tests.Regression (tests) where

import Test.Framework
import Test.Framework.Providers.HUnit
import Test.HUnit.Base

import System.FilePath.Glob.Base
import System.FilePath.Glob.Match

tests = testGroup "Regression"
   [ testGroup "Matching/compiling" .
        flip map matchCases $ \t@(b,p,s) ->
            tc (nameMatchTest t) $
               match (compile p) s == b
   , testGroup "Specific options" .
        flip map matchWithCases $ \t@(b,co,mo,p,s) ->
           tc (nameMatchTest (b,p,s)) $
              matchWith mo (compileWith co p) s == b
   , testGroup "Decompilation" .
        flip map decompileCases $ \(n,orig,s) ->
           tc n $ decompile (compile orig) == s
   ]
 where
   tc n = testCase n . assert

nameMatchTest (True ,p,s) = show p ++ " matches " ++ show s
nameMatchTest (False,p,s) = show p ++ " doesn't match " ++ show s

decompileCases =
   [ ("range-compression-1", "[*]",   "[*]")
   , ("range-compression-2", "[.]",   "[.]")
   , ("range-compression-3", "**[/]", "*[/]")
   , ("range-compression-4", "x[.]",  "x[.]")
   , ("range-compression-5", "[^~-]", "[^~-]")
   , ("range-compression-6", "[^!-]", "[^!-]")
   ]

matchCases =
   [ (True , "*"          , "")
   , (True , "**"         , "")
   , (True , "asdf"       , "asdf")
   , (True , "a*f"        , "asdf")
   , (True , "a??f"       , "asdf")
   , (True , "*"          , "asdf")
   , (True , "a*bc"       , "aXbaXbc")
   , (True , "a**bc"      , "aXbaXbc")
   , (False, "a*b"        , "aXc")
   , (True , "foo/bar.*"  , "foo/bar.baz")
   , (True , "foo/*.baz"  , "foo/bar.baz")
   , (False, "*bar.*"     , "foo/bar.baz")
   , (False, "*.baz"      , "foo/bar.baz")
   , (False, "foo*"       , "foo/bar.baz")
   , (False, "foo?bar.baz", "foo/bar.baz")
   , (True , "**/*.baz"   , "foo/bar.baz")
   , (True , "**/*"       , "foo/bar.baz")
   , (True , "**/*"       , "foo/bar/baz")
   , (True , "*/*.baz"    , "foo/bar.baz")
   , (True , "*/*"        , "foo/bar.baz")
   , (False, "*/*"        , "foo/bar/baz")
   , (False, "*.foo"      , ".bar.foo")
   , (False, "*.bar.foo"  , ".bar.foo")
   , (False, "?bar.foo"   , ".bar.foo")
   , (True , ".*.foo"     , ".bar.foo")
   , (True , ".*bar.foo"  , ".bar.foo")
   , (False, "foo.[ch]"   , "foo.a")
   , (True , "foo.[ch]"   , "foo.c")
   , (True , "foo.[ch]"   , "foo.h")
   , (False, "foo.[ch]"   , "foo.d")
   , (False, "foo.[c-h]"  , "foo.b")
   , (True , "foo.[c-h]"  , "foo.c")
   , (True , "foo.[c-h]"  , "foo.e")
   , (True , "foo.[c-h]"  , "foo.f")
   , (True , "foo.[c-h]"  , "foo.h")
   , (False, "foo.[c-h]"  , "foo.i")
   , (True , "<->3foo"    , "123foo")
   , (True , "<10-15>3foo", "123foo")
   , (True , "<0-5>23foo" , "123foo")
   , (True , "<94-200>foo", "123foo")
   , (False, "[.]x"       , ".x")
   , (False, "foo[/]bar"  , "foo/bar")
   , (False, "foo[,-0]bar", "foo/bar")
   , (True , "foo[,-0]bar", "foo.bar")
   , (True , "[]x]"       , "]")
   , (True , "[]x]"       , "x")
   , (False, "[b-a]"      , "a")
   , (False, "<4-3>"      , "3")
   , (True , "[]-b]"      , "]")
   , (False, "[]-b]"      , "-")
   , (True , "[]-b]"      , "b")
   , (True , "[]-b]"      , "a")
   , (True , "[]-]"       , "]")
   , (True , "[]-]"       , "-")
   , (True , "[#-[]"      , "&")
   , (False, "[^x]"       , "/")
   , (False, "[/]"        , "/")
   , (True , "a[^x]"      , "a.")
   , (True , "a[.]"       , "a.")
   , (False, ".//a"       , "/a")
   , (True,  ".//a"       , "a")
   , (True,  ".//a"       , "./a")
   , (True , ".*/a"       , "./a")
   , (True , ".*/a"       , "../a")
   , (True , ".*/a"       , ".foo/a")
   , (True , ".**/a"      , ".foo/a")
   , (False, ".**/a"      , "../a")
   , (False, ".**/a"      , "./a")
   , (False, ".**/a"      , "a")
   , (True , ".**/a"      , ".foo/a")
   , (True , "f**/a"      , "foo/a")
   , (True , "f**/"       , "f/")
   , (True , "f**/"       , "f///")
   , (True , "f**/x"      , "f///x")
   , (True , "f/"         , "f///")
   , (True , "f/x"        , "f///x")
   , (True , "[]"         , "[]")
   , (True , "[!]"        , "[!]")
   , (True , "[^]"        , "[^]")
   , (True , "[abc"       , "[abc")
   , (True , "<abc"       , "<abc")
   , (True , "<1-"        , "<1-")
   , (True , "[^-~]"      , "x")
   , (False, "[^-~]"      , "X")
   , (False, "[^^-~]"     , "x")
   , (False, "[^-]"       , "-")
   ]

matchWithCases =
   [ (True , compDefault, matchDefault { ignoreCase = True }, "[@-[]", "a")
   , (True , compPosix  , matchDefault                      , "a[/]b", "a[/]b")
   ]