-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.hs
83 lines (70 loc) · 2.26 KB
/
Tests.hs
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
module Tests where
import IC.TestSuite
import MP hiding (main)
lookUpTestCases
= [ ("A", [("A", 8), ("B",9), ("C",5), ("A",7)]) ==> [8,7]
, ("a", []) ==> []
, ("a", [("a", 9)]) ==> [9]
, ("a", [("b", 9)]) ==> []
]
splitTestCases
= [ (" .,", "A comma, then some words.")
==> (" , .",["A","comma","","then","some","words",""])
, ("", "")
==> ("", [""])
, (".", "A.B")
==> (".", ["A","B"])
, (" ", " A")
==> (" ", ["", "A"])
]
combineTestCases
= [ (" , .", ["A","comma","","then","some","words",""])
==> ["A"," ","comma",",",""," ","then"," ","some"," ","words",".",""]
, ("", [""])
==> [""]
, (".", ["A","B"])
==> ["A",".","B"]
, (" ", ["", "A"])
==> [""," ","A"]
]
getKeywordDefsTestCases
= [ ["$rule Reproduce this precisely -- or else!!"]
==> [("$rule","Reproduce this precisely -- or else!!")]
, ["$x Define x", "$y 55"]
==> [("$x","Define x"),("$y","55")]
, ["$a A", "$b B", "$c C"]
==> [("$a","A"),("$b","B"),("$c","C")]
, []
==> []
, ["$x-y-z $$$"]
==> [("$x-y-z","$$$")]
, ["$$ something to think about"]
==> [("$$","something to think about")]
, ["$ meanie!"]
==> [("$","meanie!")]
, ["$var Tristan Allwood"]
==> [("$var", " Tristan Allwood")]
]
expandTestCases
= [ ("The capital of $1 is $2", "$1 Peru\n$2 Lima.\n#\n$1 Polska\n$2 Poznan.")
==> "The capital of Peru is Lima."
, ("The time is $a", "$a now.")
==> "The time is now."
, ("Keywords (e.g. $x, $y, $z...) may appear anwhere, e.g. <$here>.",
"$x $a\n$y $b\n$z $c\n$here $this-is-one")
==> "Keywords (e.g. $a, $b, $c...) may appear anwhere, e.g. <$this-is-one>."
]
allTestCases
= [ TestCase "lookUp" (uncurry lookUp)
lookUpTestCases
, TestCase "split" (uncurry split)
splitTestCases
, TestCase "combine" (uncurry combine)
combineTestCases
, TestCase "getKeywordDefs" getKeywordDefs
getKeywordDefsTestCases
, TestCase "expand" (uncurry expand)
expandTestCases
]
runTests = mapM_ goTest allTestCases
main = runTests