forked from exercism/problem-specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grep.json
251 lines (251 loc) · 10.7 KB
/
grep.json
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
{
"#": [
"JSON doesn't allow for multi-line strings, so all outputs are presented ",
"here as arrays of strings. It's up to the test generator to join the ",
"lines together with line breaks.",
"",
"The tests are divided into two groups: ",
"* Grepping a single file",
"* Grepping multiple files at once",
"",
"The language track implementing this exercise should",
"ensure that when the tests run, three files are created",
"with the following contents. The file names and their",
"contents are listed in the 'files' section below."
],
"files": [
{
"name": "iliad.txt",
"contents": [
"Achilles sing, O Goddess! Peleus' son;",
"His wrath pernicious, who ten thousand woes",
"Caused to Achaia's host, sent many a soul",
"Illustrious into Ades premature,",
"And Heroes gave (so stood the will of Jove)",
"To dogs and to all ravening fowls a prey,",
"When fierce dispute had separated once",
"The noble Chief Achilles from the son",
"Of Atreus, Agamemnon, King of men."
]
},
{
"name": "midsummer-night.txt",
"contents": [
"I do entreat your grace to pardon me.",
"I know not by what power I am made bold,",
"Nor how it may concern my modesty,",
"In such a presence here to plead my thoughts;",
"But I beseech your grace that I may know",
"The worst that may befall me in this case,",
"If I refuse to wed Demetrius."
]
},
{
"name": "paradise-lost.txt",
"contents": [
"Of Mans First Disobedience, and the Fruit",
"Of that Forbidden Tree, whose mortal tast",
"Brought Death into the World, and all our woe,",
"With loss of Eden, till one greater Man",
"Restore us, and regain the blissful Seat,",
"Sing Heav'nly Muse, that on the secret top",
"Of Oreb, or of Sinai, didst inspire",
"That Shepherd, who first taught the chosen Seed"
]
}
],
"single-file": {
"description": ["Test grepping a single file"],
"cases": [
{
"description": "One file, one match, no flags",
"pattern": "Agamemnon",
"flags": [],
"files": ["iliad.txt"],
"expected": [
"Of Atreus, Agamemnon, King of men."
]
},
{
"description": "One file, several matches, no flags",
"pattern": "may",
"flags": [],
"files": ["midsummer-night.txt"],
"expected": [
"Nor how it may concern my modesty,",
"But I beseech your grace that I may know",
"The worst that may befall me in this case,"
]
},
{
"description": "One file, several matches, print line numbers flag",
"pattern": "may",
"flags": ["-n"],
"files": ["midsummer-night.txt"],
"expected": [
"3:Nor how it may concern my modesty,",
"5:But I beseech your grace that I may know",
"6:The worst that may befall me in this case,"
]
},
{
"description": "One file, one match, print file names flag",
"pattern": "Forbidden",
"flags": ["-l"],
"files": ["paradise-lost.txt"],
"expected": [
"paradise-lost.txt"
]
},
{
"description": "One file, several matches, case-insensitive flag",
"pattern": "ACHILLES",
"flags": ["-i"],
"files": ["iliad.txt"],
"expected": [
"Achilles sing, O Goddess! Peleus' son;",
"The noble Chief Achilles from the son"
]
},
{
"description": "One file, several matches, inverted flag",
"pattern": "Of",
"flags": ["-v"],
"files": ["paradise-lost.txt"],
"expected": [
"Brought Death into the World, and all our woe,",
"With loss of Eden, till one greater Man",
"Restore us, and regain the blissful Seat,",
"Sing Heav'nly Muse, that on the secret top",
"That Shepherd, who first taught the chosen Seed"
]
},
{
"description": "One file, one match, match entire lines flag",
"pattern": "With loss of Eden, till one greater Man",
"flags": ["-x"],
"files": ["paradise-lost.txt"],
"expected": [
"With loss of Eden, till one greater Man"
]
},
{
"description": "One file, one match, multiple flags",
"pattern": "OF ATREUS, Agamemnon, KIng of MEN.",
"flags": ["-n", "-i", "-x"],
"files": ["iliad.txt"],
"expected": [
"9:Of Atreus, Agamemnon, King of men."
]
},
{
"description": "One file, no matches, various flags",
"pattern": "Gandalf",
"flags": ["-n", "-l", "-x", "-i"],
"files": ["iliad.txt"],
"expected": []
}
]
},
"multiple-files": {
"description": ["Test grepping multiples files at once"],
"cases": [
{
"description": "Multiple files, one match, no flags",
"pattern": "Agamemnon",
"flags": [],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"iliad.txt:Of Atreus, Agamemnon, King of men."
]
},
{
"description": "Multiple files, several matches, no flags",
"pattern": "may",
"flags": [],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"midsummer-night.txt:Nor how it may concern my modesty,",
"midsummer-night.txt:But I beseech your grace that I may know",
"midsummer-night.txt:The worst that may befall me in this case,"
]
},
{
"description": "Multiple files, several matches, print line numbers flag",
"pattern": "that",
"flags": ["-n"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"midsummer-night.txt:5:But I beseech your grace that I may know",
"midsummer-night.txt:6:The worst that may befall me in this case,",
"paradise-lost.txt:2:Of that Forbidden Tree, whose mortal tast",
"paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top"
]
},
{
"description": "Multiple files, one match, print file names flag",
"pattern": "who",
"flags": ["-l"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"iliad.txt",
"paradise-lost.txt"
]
},
{
"description": "Multiple files, several matches, case-insensitive flag",
"pattern": "TO",
"flags": ["-i"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"iliad.txt:Caused to Achaia's host, sent many a soul",
"iliad.txt:Illustrious into Ades premature,",
"iliad.txt:And Heroes gave (so stood the will of Jove)",
"iliad.txt:To dogs and to all ravening fowls a prey,",
"midsummer-night.txt:I do entreat your grace to pardon me.",
"midsummer-night.txt:In such a presence here to plead my thoughts;",
"midsummer-night.txt:If I refuse to wed Demetrius.",
"paradise-lost.txt:Brought Death into the World, and all our woe,",
"paradise-lost.txt:Restore us, and regain the blissful Seat,",
"paradise-lost.txt:Sing Heav'nly Muse, that on the secret top"
]
},
{
"description": "Multiple files, several matches, inverted flag",
"pattern": "a",
"flags": ["-v"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"iliad.txt:Achilles sing, O Goddess! Peleus' son;",
"iliad.txt:The noble Chief Achilles from the son",
"midsummer-night.txt:If I refuse to wed Demetrius."
]
},
{
"description": "Multiple files, one match, match entire lines flag",
"pattern": "But I beseech your grace that I may know",
"flags": ["-x"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"midsummer-night.txt:But I beseech your grace that I may know"
]
},
{
"description": "Multiple files, one match, multiple flags",
"pattern": "WITH LOSS OF EDEN, TILL ONE GREATER MAN",
"flags": ["-n", "-i", "-x"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": [
"paradise-lost.txt:4:With loss of Eden, till one greater Man"
]
},
{
"description": "Multiple files, no matches, various flags",
"pattern": "Frodo",
"flags": ["-n", "-l", "-x", "-i"],
"files": ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
"expected": []
}
]
}
}