trackler 2.2.1.97 → 2.2.1.98

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/custom-set/canonical-data.json +139 -69
  4. data/tracks/go/README.md +6 -1
  5. data/tracks/go/exercises/accumulate/accumulate_test.go +2 -5
  6. data/tracks/go/exercises/allergies/allergies_test.go +5 -11
  7. data/tracks/go/exercises/anagram/anagram_test.go +2 -6
  8. data/tracks/go/exercises/atbash-cipher/atbash_cipher_test.go +2 -5
  9. data/tracks/go/exercises/beer-song/beer_test.go +2 -5
  10. data/tracks/go/exercises/bob/bob_test.go +2 -2
  11. data/tracks/go/exercises/bracket-push/bracket_push_test.go +2 -5
  12. data/tracks/go/exercises/change/change_test.go +2 -2
  13. data/tracks/go/exercises/etl/etl_test.go +2 -5
  14. data/tracks/go/exercises/grains/grains_test.go +2 -5
  15. data/tracks/go/exercises/isogram/isogram_test.go +2 -5
  16. data/tracks/go/exercises/octal/octal_test.go +2 -5
  17. data/tracks/go/exercises/pangram/.meta/gen.go +5 -3
  18. data/tracks/go/exercises/pangram/cases_test.go +2 -2
  19. data/tracks/go/exercises/perfect-numbers/.meta/gen.go +5 -3
  20. data/tracks/go/exercises/perfect-numbers/cases_test.go +2 -2
  21. data/tracks/go/exercises/phone-number/.meta/gen.go +5 -3
  22. data/tracks/go/exercises/phone-number/cases_test.go +2 -2
  23. data/tracks/go/exercises/phone-number/phone_number_test.go +6 -15
  24. data/tracks/go/exercises/pig-latin/.meta/gen.go +5 -3
  25. data/tracks/go/exercises/pig-latin/cases_test.go +2 -2
  26. data/tracks/go/exercises/transpose/transpose_test.go +2 -2
  27. data/tracks/ocaml/docs/INSTALLATION.md +35 -4
  28. data/tracks/ocaml/exercises/atbash-cipher/{HINTS.md → .meta/hints.md} +0 -0
  29. data/tracks/ocaml/exercises/bob/{HINTS.md → .meta/hints.md} +0 -0
  30. data/tracks/ocaml/exercises/prime-factors/example.ml +2 -3
  31. data/tracks/perl6/.travis.yml +1 -0
  32. data/tracks/perl6/bin/exercise-gen.pl6 +38 -33
  33. data/tracks/perl6/lib/Exercism/Generator.pm6 +37 -0
  34. data/tracks/perl6/t/generated-tests.t +18 -0
  35. data/tracks/ruby/exercises/accumulate/README.md +0 -3
  36. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a879165bbaf3374166c71dc34a41c6aec1bb4810
4
- data.tar.gz: c2523fd9d3a926cc23467b989899bdf68f0fa565
3
+ metadata.gz: 61557d8c8f53297686afbfb79d34fd4bb855673b
4
+ data.tar.gz: 0e787d40634a430d4019195d58f4fdff356f82ae
5
5
  SHA512:
6
- metadata.gz: 1cc0663e27885b9b49fe12f96d9157edd8e461124f5dec5d6e6cd80e479086938f1064cd8bc14eaba7e81b52d491f1e2332c3d754f8c81b31063939d2a541d3d
7
- data.tar.gz: a0dac94954516db51e090848ee10285b9303d1e5b6f0fb3ad23a1a4e465c50cadab72b7d98503922a9c8e1c5a2cf768ed6411e69513a1c34fb0b16f52621d5b8
6
+ metadata.gz: bfd3d1d4c263d6dc3bc615d67eb273808855a2c2bfee91201963dcc168350f1b30c8fe8efe04a145d20900976a824d52a6e6540f686c42c1a81cdbf5c3108a54
7
+ data.tar.gz: a203c0f9128acfb983935569b854b134213a3da2aa254fc3a6e94565c2b3b22df296fc3027783cce311c64c22eb9415cb926c8c1e402db33f6cdcef96c52263f
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.97"
2
+ VERSION = "2.2.1.98"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "exercise": "custom-set",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "comments": [
5
5
  "These tests cover the core components of a set data structure: checking",
6
6
  "presence, adding, comparing and basic set operations. Other features",
@@ -18,13 +18,17 @@
18
18
  {
19
19
  "description": "sets with no elements are empty",
20
20
  "property": "empty",
21
- "set": [],
21
+ "input": {
22
+ "set": []
23
+ },
22
24
  "expected": true
23
25
  },
24
26
  {
25
27
  "description": "sets with elements are not empty",
26
28
  "property": "empty",
27
- "set": [1],
29
+ "input": {
30
+ "set": [1]
31
+ },
28
32
  "expected": false
29
33
  }
30
34
  ]
@@ -35,22 +39,28 @@
35
39
  {
36
40
  "description": "nothing is contained in an empty set",
37
41
  "property": "contains",
38
- "set": [],
39
- "element": 1,
42
+ "input": {
43
+ "set": [],
44
+ "element": 1
45
+ },
40
46
  "expected": false
41
47
  },
42
48
  {
43
49
  "description": "when the element is in the set",
44
50
  "property": "contains",
45
- "set": [1, 2, 3],
46
- "element": 1,
51
+ "input": {
52
+ "set": [1, 2, 3],
53
+ "element": 1
54
+ },
47
55
  "expected": true
48
56
  },
49
57
  {
50
58
  "description": "when the element is not in the set",
51
59
  "property": "contains",
52
- "set": [1, 2, 3],
53
- "element": 4,
60
+ "input": {
61
+ "set": [1, 2, 3],
62
+ "element": 4
63
+ },
54
64
  "expected": false
55
65
  }
56
66
  ]
@@ -61,43 +71,55 @@
61
71
  {
62
72
  "description": "empty set is a subset of another empty set",
63
73
  "property": "subset",
64
- "set1": [],
65
- "set2": [],
74
+ "input": {
75
+ "set1": [],
76
+ "set2": []
77
+ },
66
78
  "expected": true
67
79
  },
68
80
  {
69
81
  "description": "empty set is a subset of non-empty set",
70
82
  "property": "subset",
71
- "set1": [],
72
- "set2": [1],
83
+ "input": {
84
+ "set1": [],
85
+ "set2": [1]
86
+ },
73
87
  "expected": true
74
88
  },
75
89
  {
76
90
  "description": "non-empty set is not a subset of empty set",
77
91
  "property": "subset",
78
- "set1": [1],
79
- "set2": [],
92
+ "input": {
93
+ "set1": [1],
94
+ "set2": []
95
+ },
80
96
  "expected": false
81
97
  },
82
98
  {
83
99
  "description": "set is a subset of set with exact same elements",
84
100
  "property": "subset",
85
- "set1": [1, 2, 3],
86
- "set2": [1, 2, 3],
101
+ "input": {
102
+ "set1": [1, 2, 3],
103
+ "set2": [1, 2, 3]
104
+ },
87
105
  "expected": true
88
106
  },
89
107
  {
90
108
  "description": "set is a subset of larger set with same elements",
91
109
  "property": "subset",
92
- "set1": [1, 2, 3],
93
- "set2": [4, 1, 2, 3],
110
+ "input": {
111
+ "set1": [1, 2, 3],
112
+ "set2": [4, 1, 2, 3]
113
+ },
94
114
  "expected": true
95
115
  },
96
116
  {
97
117
  "description": "set is not a subset of set that does not contain its elements",
98
118
  "property": "subset",
99
- "set1": [1, 2, 3],
100
- "set2": [4, 1, 3],
119
+ "input": {
120
+ "set1": [1, 2, 3],
121
+ "set2": [4, 1, 3]
122
+ },
101
123
  "expected": false
102
124
  }
103
125
  ]
@@ -108,36 +130,46 @@
108
130
  {
109
131
  "description": "the empty set is disjoint with itself",
110
132
  "property": "disjoint",
111
- "set1": [],
112
- "set2": [],
133
+ "input": {
134
+ "set1": [],
135
+ "set2": []
136
+ },
113
137
  "expected": true
114
138
  },
115
139
  {
116
140
  "description": "empty set is disjoint with non-empty set",
117
141
  "property": "disjoint",
118
- "set1": [],
119
- "set2": [1],
142
+ "input": {
143
+ "set1": [],
144
+ "set2": [1]
145
+ },
120
146
  "expected": true
121
147
  },
122
148
  {
123
149
  "description": "non-empty set is disjoint with empty set",
124
150
  "property": "disjoint",
125
- "set1": [1],
126
- "set2": [],
151
+ "input": {
152
+ "set1": [1],
153
+ "set2": []
154
+ },
127
155
  "expected": true
128
156
  },
129
157
  {
130
158
  "description": "sets are not disjoint if they share an element",
131
159
  "property": "disjoint",
132
- "set1": [1, 2],
133
- "set2": [2, 3],
160
+ "input": {
161
+ "set1": [1, 2],
162
+ "set2": [2, 3]
163
+ },
134
164
  "expected": false
135
165
  },
136
166
  {
137
167
  "description": "sets are disjoint if they share no elements",
138
168
  "property": "disjoint",
139
- "set1": [1, 2],
140
- "set2": [3, 4],
169
+ "input": {
170
+ "set1": [1, 2],
171
+ "set2": [3, 4]
172
+ },
141
173
  "expected": true
142
174
  }
143
175
  ]
@@ -148,43 +180,55 @@
148
180
  {
149
181
  "description": "empty sets are equal",
150
182
  "property": "equal",
151
- "set1": [],
152
- "set2": [],
183
+ "input": {
184
+ "set1": [],
185
+ "set2": []
186
+ },
153
187
  "expected": true
154
188
  },
155
189
  {
156
190
  "description": "empty set is not equal to non-empty set",
157
191
  "property": "equal",
158
- "set1": [],
159
- "set2": [1, 2, 3],
192
+ "input": {
193
+ "set1": [],
194
+ "set2": [1, 2, 3]
195
+ },
160
196
  "expected": false
161
197
  },
162
198
  {
163
199
  "description": "non-empty set is not equal to empty set",
164
200
  "property": "equal",
165
- "set1": [1, 2, 3],
166
- "set2": [],
201
+ "input": {
202
+ "set1": [1, 2, 3],
203
+ "set2": []
204
+ },
167
205
  "expected": false
168
206
  },
169
207
  {
170
208
  "description": "sets with the same elements are equal",
171
209
  "property": "equal",
172
- "set1": [1, 2],
173
- "set2": [2, 1],
210
+ "input": {
211
+ "set1": [1, 2],
212
+ "set2": [2, 1]
213
+ },
174
214
  "expected": true
175
215
  },
176
216
  {
177
217
  "description": "sets with different elements are not equal",
178
218
  "property": "equal",
179
- "set1": [1, 2, 3],
180
- "set2": [1, 2, 4],
219
+ "input": {
220
+ "set1": [1, 2, 3],
221
+ "set2": [1, 2, 4]
222
+ },
181
223
  "expected": false
182
224
  },
183
225
  {
184
226
  "description": "set is not equal to larger set with same elements",
185
227
  "property": "equal",
186
- "set1": [1, 2, 3],
187
- "set2": [1, 2, 3, 4],
228
+ "input": {
229
+ "set1": [1, 2, 3],
230
+ "set2": [1, 2, 3, 4]
231
+ },
188
232
  "expected": false
189
233
  }
190
234
  ]
@@ -221,36 +265,46 @@
221
265
  {
222
266
  "description": "intersection of two empty sets is an empty set",
223
267
  "property": "intersection",
224
- "set1": [],
225
- "set2": [],
268
+ "input": {
269
+ "set1": [],
270
+ "set2": []
271
+ },
226
272
  "expected": []
227
273
  },
228
274
  {
229
275
  "description": "intersection of an empty set and non-empty set is an empty set",
230
276
  "property": "intersection",
231
- "set1": [],
232
- "set2": [3, 2, 5],
277
+ "input": {
278
+ "set1": [],
279
+ "set2": [3, 2, 5]
280
+ },
233
281
  "expected": []
234
282
  },
235
283
  {
236
284
  "description": "intersection of a non-empty set and an empty set is an empty set",
237
285
  "property": "intersection",
238
- "set1": [1, 2, 3, 4],
239
- "set2": [],
286
+ "input": {
287
+ "set1": [1, 2, 3, 4],
288
+ "set2": []
289
+ },
240
290
  "expected": []
241
291
  },
242
292
  {
243
293
  "description": "intersection of two sets with no shared elements is an empty set",
244
294
  "property": "intersection",
245
- "set1": [1, 2, 3],
246
- "set2": [4, 5, 6],
295
+ "input": {
296
+ "set1": [1, 2, 3],
297
+ "set2": [4, 5, 6]
298
+ },
247
299
  "expected": []
248
300
  },
249
301
  {
250
302
  "description": "intersection of two sets with shared elements is a set of the shared elements",
251
303
  "property": "intersection",
252
- "set1": [1, 2, 3, 4],
253
- "set2": [3, 2, 5],
304
+ "input": {
305
+ "set1": [1, 2, 3, 4],
306
+ "set2": [3, 2, 5]
307
+ },
254
308
  "expected": [2, 3]
255
309
  }
256
310
  ]
@@ -261,29 +315,37 @@
261
315
  {
262
316
  "description": "difference of two empty sets is an empty set",
263
317
  "property": "difference",
264
- "set1": [],
265
- "set2": [],
318
+ "input": {
319
+ "set1": [],
320
+ "set2": []
321
+ },
266
322
  "expected": []
267
323
  },
268
324
  {
269
325
  "description": "difference of empty set and non-empty set is an empty set",
270
326
  "property": "difference",
271
- "set1": [],
272
- "set2": [3, 2, 5],
327
+ "input": {
328
+ "set1": [],
329
+ "set2": [3, 2, 5]
330
+ },
273
331
  "expected": []
274
332
  },
275
333
  {
276
334
  "description": "difference of a non-empty set and an empty set is the non-empty set",
277
335
  "property": "difference",
278
- "set1": [1, 2, 3, 4],
279
- "set2": [],
336
+ "input": {
337
+ "set1": [1, 2, 3, 4],
338
+ "set2": []
339
+ },
280
340
  "expected": [1, 2, 3, 4]
281
341
  },
282
342
  {
283
343
  "description": "difference of two non-empty sets is a set of elements that are only in the first set",
284
344
  "property": "difference",
285
- "set1": [3, 2, 1],
286
- "set2": [2, 4],
345
+ "input": {
346
+ "set1": [3, 2, 1],
347
+ "set2": [2, 4]
348
+ },
287
349
  "expected": [1, 3]
288
350
  }
289
351
  ]
@@ -294,29 +356,37 @@
294
356
  {
295
357
  "description": "union of empty sets is an empty set",
296
358
  "property": "union",
297
- "set1": [],
298
- "set2": [],
359
+ "input": {
360
+ "set1": [],
361
+ "set2": []
362
+ },
299
363
  "expected": []
300
364
  },
301
365
  {
302
366
  "description": "union of an empty set and non-empty set is the non-empty set",
303
367
  "property": "union",
304
- "set1": [],
305
- "set2": [2],
368
+ "input": {
369
+ "set1": [],
370
+ "set2": [2]
371
+ },
306
372
  "expected": [2]
307
373
  },
308
374
  {
309
375
  "description": "union of a non-empty set and empty set is the non-empty set",
310
376
  "property": "union",
311
- "set1": [1, 3],
312
- "set2": [],
377
+ "input": {
378
+ "set1": [1, 3],
379
+ "set2": []
380
+ },
313
381
  "expected": [1, 3]
314
382
  },
315
383
  {
316
384
  "description": "union of non-empty sets contains all unique elements",
317
385
  "property": "union",
318
- "set1": [1, 3],
319
- "set2": [2, 3],
386
+ "input": {
387
+ "set1": [1, 3],
388
+ "set2": [2, 3]
389
+ },
320
390
  "expected": [3, 2, 1]
321
391
  }
322
392
  ]
data/tracks/go/README.md CHANGED
@@ -221,7 +221,12 @@ directory within each exercise that makes use of a test cases generator. This
221
221
  Whenever the shared JSON data changes, the test cases will need to be regenerated.
222
222
  The generator will first look for a local copy of the **problem-specifications** repository.
223
223
  If there isn't one it will attempt to get the relevant json data for the
224
- exercise from the **problem-specifications** repository on GitHub.
224
+ exercise from the **problem-specifications** repository on GitHub. The generator
225
+ uses the GitHub API to find some information about exercises when it cannot
226
+ find a local copy of **problem-specifications**. This can cause throttling
227
+ issues if working with a large number of exercise. *We therefore recommend
228
+ using a local copy of the repository when possible* (remember to keep it
229
+ current :smile:).
225
230
 
226
231
  To use a local copy of the **problem-specifications** repository, make sure that it has been
227
232
  cloned into the same parent-directory as the **go** repository.
@@ -36,14 +36,11 @@ func TestAccumulate(t *testing.T) {
36
36
  }
37
37
 
38
38
  func BenchmarkAccumulate(b *testing.B) {
39
- b.StopTimer()
40
- for _, test := range tests {
41
- b.StartTimer()
39
+ for i := 0; i < b.N; i++ {
42
40
 
43
- for i := 0; i < b.N; i++ {
41
+ for _, test := range tests {
44
42
  Accumulate(test.given, test.converter)
45
43
  }
46
44
 
47
- b.StopTimer()
48
45
  }
49
46
  }
@@ -16,14 +16,11 @@ func TestAllergies(t *testing.T) {
16
16
  }
17
17
 
18
18
  func BenchmarkAllergies(b *testing.B) {
19
- b.StopTimer()
20
- for _, test := range allergicToTests {
21
- b.StartTimer()
19
+ for i := 0; i < b.N; i++ {
22
20
 
23
- for i := 0; i < b.N; i++ {
21
+ for _, test := range allergicToTests {
24
22
  Allergies(test.score)
25
23
  }
26
- b.StopTimer()
27
24
  }
28
25
  }
29
26
 
@@ -41,15 +38,12 @@ func TestAllergicTo(t *testing.T) {
41
38
  }
42
39
 
43
40
  func BenchmarkAllergicTo(b *testing.B) {
44
- b.StopTimer()
45
- for _, test := range allergicToTests {
46
- for _, response := range test.expected {
47
- b.StartTimer()
41
+ for i := 0; i < b.N; i++ {
42
+ for _, test := range allergicToTests {
48
43
 
49
- for i := 0; i < b.N; i++ {
44
+ for _, response := range test.expected {
50
45
  AllergicTo(test.score, response.substance)
51
46
  }
52
- b.StopTimer()
53
47
  }
54
48
  }
55
49
  }
@@ -35,16 +35,12 @@ func TestDetectAnagrams(t *testing.T) {
35
35
 
36
36
  func BenchmarkDetectAnagrams(b *testing.B) {
37
37
 
38
- b.StopTimer()
38
+ for i := 0; i < b.N; i++ {
39
39
 
40
- for _, tt := range testCases {
41
- b.StartTimer()
42
-
43
- for i := 0; i < b.N; i++ {
40
+ for _, tt := range testCases {
44
41
  Detect(tt.subject, tt.candidates)
45
42
  }
46
43
 
47
- b.StopTimer()
48
44
  }
49
45
 
50
46
  }
@@ -12,14 +12,11 @@ func TestAtbash(t *testing.T) {
12
12
  }
13
13
 
14
14
  func BenchmarkAtbash(b *testing.B) {
15
- b.StopTimer()
16
- for _, test := range tests {
17
- b.StartTimer()
15
+ for i := 0; i < b.N; i++ {
18
16
 
19
- for i := 0; i < b.N; i++ {
17
+ for _, test := range tests {
20
18
  Atbash(test.s)
21
19
  }
22
20
 
23
- b.StopTimer()
24
21
  }
25
22
  }
@@ -110,15 +110,12 @@ func TestSeveralVerses(t *testing.T) {
110
110
  }
111
111
 
112
112
  func BenchmarkSeveralVerses(b *testing.B) {
113
- b.StopTimer()
114
- for _, tt := range versesTestCases {
115
- b.StartTimer()
113
+ for i := 0; i < b.N; i++ {
116
114
 
117
- for i := 0; i < b.N; i++ {
115
+ for _, tt := range versesTestCases {
118
116
  Verses(tt.upperBound, tt.lowerBound)
119
117
  }
120
118
 
121
- b.StopTimer()
122
119
  }
123
120
  }
124
121
 
@@ -17,8 +17,8 @@ func TestHey(t *testing.T) {
17
17
  }
18
18
 
19
19
  func BenchmarkHey(b *testing.B) {
20
- for _, tt := range testCases {
21
- for i := 0; i < b.N; i++ {
20
+ for i := 0; i < b.N; i++ {
21
+ for _, tt := range testCases {
22
22
  Hey(tt.input)
23
23
  }
24
24
  }
@@ -20,12 +20,9 @@ func TestBracket(t *testing.T) {
20
20
  }
21
21
 
22
22
  func BenchmarkBracket(b *testing.B) {
23
- b.StopTimer()
24
- for _, tt := range testCases {
25
- b.StartTimer()
26
- for i := 0; i < b.N; i++ {
23
+ for i := 0; i < b.N; i++ {
24
+ for _, tt := range testCases {
27
25
  Bracket(tt.input)
28
26
  }
29
- b.StopTimer()
30
27
  }
31
28
  }
@@ -32,8 +32,8 @@ func TestChange(t *testing.T) {
32
32
  }
33
33
 
34
34
  func BenchmarkChange(b *testing.B) {
35
- for _, tc := range testCases {
36
- for i := 0; i < b.N; i++ {
35
+ for i := 0; i < b.N; i++ {
36
+ for _, tc := range testCases {
37
37
  Change(tc.coins, tc.target)
38
38
  }
39
39
  }
@@ -77,14 +77,11 @@ func TestTransform(t *testing.T) {
77
77
  }
78
78
 
79
79
  func BenchmarkTransform(b *testing.B) {
80
- b.StopTimer()
81
- for _, tt := range transformTests {
82
- b.StartTimer()
80
+ for i := 0; i < b.N; i++ {
83
81
 
84
- for i := 0; i < b.N; i++ {
82
+ for _, tt := range transformTests {
85
83
  Transform(map[int][]string(tt.input))
86
84
  }
87
85
 
88
- b.StopTimer()
89
86
  }
90
87
  }
@@ -34,16 +34,13 @@ func TestTotal(t *testing.T) {
34
34
  }
35
35
 
36
36
  func BenchmarkSquare(b *testing.B) {
37
- b.StopTimer()
38
37
 
39
- for _, test := range squareTests {
40
- b.StartTimer()
38
+ for i := 0; i < b.N; i++ {
41
39
 
42
- for i := 0; i < b.N; i++ {
40
+ for _, test := range squareTests {
43
41
  Square(test.input)
44
42
  }
45
43
 
46
- b.StopTimer()
47
44
  }
48
45
  }
49
46
 
@@ -13,14 +13,11 @@ func TestIsIsogram(t *testing.T) {
13
13
  }
14
14
 
15
15
  func BenchmarkIsIsogram(b *testing.B) {
16
- b.StopTimer()
17
- for _, c := range testCases {
18
- b.StartTimer()
16
+ for i := 0; i < b.N; i++ {
19
17
 
20
- for i := 0; i < b.N; i++ {
18
+ for _, c := range testCases {
21
19
  IsIsogram(c.input)
22
20
  }
23
21
 
24
- b.StopTimer()
25
22
  }
26
23
  }
@@ -37,15 +37,12 @@ func TestParseOctal(t *testing.T) {
37
37
  }
38
38
 
39
39
  func BenchmarkParseOctal(b *testing.B) {
40
- b.StopTimer()
41
40
 
42
- for _, test := range testCases {
43
- b.StartTimer()
41
+ for i := 0; i < b.N; i++ {
44
42
 
45
- for i := 0; i < b.N; i++ {
43
+ for _, test := range testCases {
46
44
  ParseOctal(test.input)
47
45
  }
48
46
 
49
- b.StopTimer()
50
47
  }
51
48
  }
@@ -31,8 +31,10 @@ type js struct {
31
31
  type oneCase struct {
32
32
  Description string
33
33
  Property string
34
- Input string
35
- Expected bool
34
+ Input struct {
35
+ Sentence string
36
+ }
37
+ Expected bool
36
38
  }
37
39
 
38
40
  // Template to generate test cases.
@@ -47,7 +49,7 @@ var testCases = []struct {
47
49
  }{ {{range .J.Cases}}{{range .Cases}}
48
50
  {
49
51
  description: {{printf "%q" .Description}},
50
- input: {{printf "%q" .Input}},
52
+ input: {{printf "%q" .Input.Sentence}},
51
53
  expected: {{printf "%t" .Expected}},
52
54
  },{{end}}{{end}}
53
55
  }
@@ -1,8 +1,8 @@
1
1
  package pangram
2
2
 
3
3
  // Source: exercism/problem-specifications
4
- // Commit: d79e13e pangram: fix duplicative case for a missing 'x' (#958)
5
- // Problem Specifications Version: 1.3.0
4
+ // Commit: c319f15 pangram: Apply new "input" policy
5
+ // Problem Specifications Version: 1.4.0
6
6
 
7
7
  var testCases = []struct {
8
8
  description string
@@ -32,8 +32,10 @@ type js struct {
32
32
  type oneCase struct {
33
33
  Description string
34
34
  Property string
35
- Input int64
36
- Expected interface{}
35
+ Input struct {
36
+ Number int64
37
+ }
38
+ Expected interface{}
37
39
  }
38
40
 
39
41
  func (c oneCase) Valid() bool {
@@ -78,7 +80,7 @@ var classificationTestCases = []struct {
78
80
  }{ {{range .J.Cases}} {{range .Cases}}
79
81
  {
80
82
  description: "{{.Description}}",
81
- input: {{.Input}},
83
+ input: {{.Input.Number}},
82
84
  {{if .Valid}} ok: true,
83
85
  expected: {{.ExpectedClassification}},
84
86
  {{- else}} ok: false,
@@ -1,8 +1,8 @@
1
1
  package perfect
2
2
 
3
3
  // Source: exercism/problem-specifications
4
- // Commit: 924bb7a perfect-numbers: fix misleading test description
5
- // Problem Specifications Version: 1.0.1
4
+ // Commit: d7c0227 perfect-numbers: Apply new "input" policy
5
+ // Problem Specifications Version: 1.1.0
6
6
 
7
7
  var classificationTestCases = []struct {
8
8
  description string
@@ -47,8 +47,10 @@ type js struct {
47
47
  Description string
48
48
  Cases []struct {
49
49
  Description string
50
- Phrase string
51
- Expected string
50
+ Input struct {
51
+ Phrase string
52
+ }
53
+ Expected string
52
54
  }
53
55
  }
54
56
  }
@@ -69,7 +71,7 @@ var numberTests = []struct {
69
71
  }{
70
72
  {{range .Cases}}{
71
73
  description: {{printf "%q" .Description}},
72
- input: {{printf "%q" .Phrase}},
74
+ input: {{printf "%q" .Input.Phrase}},
73
75
  {{if expectErr .Expected}} expectErr: {{expectErr .Expected | printf "%v" }},
74
76
  {{else}} number: {{printf "%q" .Expected}},
75
77
  areaCode: {{areacode .Expected | printf "%q" }},
@@ -1,8 +1,8 @@
1
1
  package phonenumber
2
2
 
3
3
  // Source: exercism/problem-specifications
4
- // Commit: 8380763 phone-number: add missing edge cases (#1090)
5
- // Problem Specifications Version: 1.3.0
4
+ // Commit: 0783171 phone-number: Apply new "input" policy
5
+ // Problem Specifications Version: 1.4.0
6
6
 
7
7
  // Cleanup user-entered phone numbers
8
8
  var numberTests = []struct {
@@ -24,13 +24,10 @@ func TestNumber(t *testing.T) {
24
24
  }
25
25
 
26
26
  func BenchmarkNumber(b *testing.B) {
27
- b.StopTimer()
28
- for _, test := range numberTests {
29
- b.StartTimer()
30
- for i := 0; i < b.N; i++ {
27
+ for i := 0; i < b.N; i++ {
28
+ for _, test := range numberTests {
31
29
  Number(test.input)
32
30
  }
33
- b.StopTimer()
34
31
  }
35
32
  }
36
33
 
@@ -54,13 +51,10 @@ func TestAreaCode(t *testing.T) {
54
51
  }
55
52
 
56
53
  func BenchmarkAreaCode(b *testing.B) {
57
- b.StopTimer()
58
- for _, test := range numberTests {
59
- b.StartTimer()
60
- for i := 0; i < b.N; i++ {
54
+ for i := 0; i < b.N; i++ {
55
+ for _, test := range numberTests {
61
56
  AreaCode(test.input)
62
57
  }
63
- b.StopTimer()
64
58
  }
65
59
  }
66
60
 
@@ -84,12 +78,9 @@ func TestFormat(t *testing.T) {
84
78
  }
85
79
 
86
80
  func BenchmarkFormat(b *testing.B) {
87
- b.StopTimer()
88
- for _, test := range numberTests {
89
- b.StartTimer()
90
- for i := 0; i < b.N; i++ {
81
+ for i := 0; i < b.N; i++ {
82
+ for _, test := range numberTests {
91
83
  Format(test.input)
92
84
  }
93
- b.StopTimer()
94
85
  }
95
86
  }
@@ -35,8 +35,10 @@ type oneLevel struct {
35
35
  type oneCase struct {
36
36
  Description string
37
37
  Property string
38
- Input string
39
- Expected string
38
+ Input struct {
39
+ Phrase string
40
+ }
41
+ Expected string
40
42
  }
41
43
 
42
44
  // Template to generate test cases.
@@ -51,7 +53,7 @@ var testCases = []struct {
51
53
  }{ {{range .J.Cases}} {{range .Cases}}
52
54
  {
53
55
  description: {{printf "%q" .Description}},
54
- input: {{printf "%#v" .Input}},
56
+ input: {{printf "%#v" .Input.Phrase}},
55
57
  expected: {{printf "%#v" .Expected}},
56
58
  },{{end}}{{end}}
57
59
  }
@@ -1,8 +1,8 @@
1
1
  package piglatin
2
2
 
3
3
  // Source: exercism/problem-specifications
4
- // Commit: b5ddd0a pig-latin: tests for Y as a vowel (#904)
5
- // Problem Specifications Version: 1.1.0
4
+ // Commit: d77de78 pig-latin: Apply new "input" policy
5
+ // Problem Specifications Version: 1.2.0
6
6
 
7
7
  var testCases = []struct {
8
8
  description string
@@ -36,8 +36,8 @@ func min(a, b int) int {
36
36
  }
37
37
 
38
38
  func BenchmarkTranspose(b *testing.B) {
39
- for _, test := range testCases {
40
- for i := 0; i < b.N; i++ {
39
+ for i := 0; i < b.N; i++ {
40
+ for _, test := range testCases {
41
41
  Transpose(test.input)
42
42
  }
43
43
  }
@@ -1,5 +1,36 @@
1
- Follow the [installation instructions](https://github.com/realworldocaml/book/wiki/Installation-Instructions) of the excellent [Real World OCaml](https://realworldocaml.org/) book. Afterwards be sure to install [OUnit](http://ounit.forge.ocamlcore.org/) using
1
+ 1. Install the OCaml compiler (`ocaml`) and package manager (`opam`).
2
+
3
+ The excellent [Real World OCaml](https://realworldocaml.org/) book has
4
+ [installation
5
+ instructions](https://github.com/realworldocaml/book/wiki/Installation-Instructions)
6
+ for a variety of operating systems.
7
+
8
+ 2. If you followed the instructions from Real World OCaml, it is likely that
9
+ your system's OCaml compiler is not the latest version.
10
+
11
+ To see a list of available versions and the one you have currently installed,
12
+ run:
13
+
14
+ ```bash
15
+ opam switch
16
+ ```
17
+
18
+ Note which version is the latest and install it by running:
19
+
20
+ ```bash
21
+ opam switch <version-number>
22
+ ```
23
+
24
+ For example, if the latest version is 4.06.0, you will run:
25
+
26
+ ```bash
27
+ opam switch 4.06.0
28
+ ```
29
+
30
+ 3. Install the Core and [OUnit](http://ounit.forge.ocamlcore.org/) packages,
31
+ which are necessary in order to run the exercise tests:
32
+
33
+ ```bash
34
+ opam install core ounit
35
+ ```
2
36
 
3
- ```bash
4
- opam install ounit
5
- ```
@@ -1,9 +1,8 @@
1
1
  open Core
2
2
 
3
3
  let square_root_trunc n =
4
- (* Square root is not defined on int64 but it is on big_int *)
5
- let open Big_int in
6
- big_int_of_int64 n |> sqrt_big_int |> int64_of_big_int
4
+ (* Square root is not defined on int64 *)
5
+ Int64.to_float n |> sqrt |> Int64.of_float
7
6
 
8
7
  let rec factors_of' = function
9
8
  | 1L -> []
@@ -16,4 +16,5 @@ script:
16
16
  exercism-rakudo-star prove /exercism
17
17
  --exec perl6
18
18
  --recurse
19
+ --directives
19
20
  --jobs 2
@@ -1,25 +1,33 @@
1
1
  #!/usr/bin/env perl6
2
2
  use v6;
3
- use Template::Mustache;
4
3
  use YAML::Parser::LibYAML;
4
+ use lib (my $base-dir = $?FILE.IO.resolve.parent.parent).add('lib');
5
+ use Exercism::Generator;
5
6
 
6
- my $base-dir = $?FILE.IO.resolve.parent.parent;
7
- my @exercises;
7
+ my %*SUB-MAIN-OPTS = :named-anywhere;
8
8
 
9
- if $base-dir.child('problem-specifications') !~~ :d {
10
- warn 'problem-specifications directory not found; some exercises may generate incorrectly.';
9
+ proto sub MAIN (|) {
10
+ if $base-dir.add('problem-specifications') !~~ :d {
11
+ note 'problem-specifications directory not found; some exercises may generate incorrectly.';
12
+ }
13
+ if $base-dir.add('bin/configlet') !~~ :f {
14
+ note 'configlet not found; README.md file(s) will not be generated.';
15
+ }
16
+ {*}
11
17
  }
12
18
 
13
- if @*ARGS {
14
- if @*ARGS[0] eq '--all' {
15
- push @exercises, .basename for $base-dir.child('exercises').dir;
16
- } else {
17
- @exercises = @*ARGS;
18
- }
19
- } else {
19
+ multi sub MAIN (Bool:D :$all where *.so) {
20
+ generate .basename for $base-dir.add('exercises').dir;
21
+ }
22
+
23
+ multi sub MAIN (*@exercises) {
24
+ @exercises».&generate;
25
+ }
26
+
27
+ multi sub MAIN {
20
28
  say 'No args given; working in current directory.';
21
29
  if 'example.yaml'.IO ~~ :f {
22
- push @exercises, $*CWD.IO.basename;
30
+ generate $*CWD.IO.basename;
23
31
  } else {
24
32
  say 'example.yaml not found in current directory; exiting.';
25
33
  exit;
@@ -28,37 +36,34 @@ if @*ARGS {
28
36
 
29
37
  my @dir-not-found;
30
38
  my @yaml-not-found;
31
- for @exercises -> $exercise {
32
- if (my $exercise-dir = $base-dir.child("exercises/$exercise")) !~~ :d {
39
+
40
+ sub generate ($exercise) {
41
+ if (my $exercise-dir = $base-dir.add("exercises/$exercise")) !~~ :d {
33
42
  push @dir-not-found, $exercise;
34
43
  next;
35
44
  }
36
- if (my $yaml-file = $exercise-dir.child('example.yaml')) !~~ :f {
45
+ if (my $yaml-file = $exercise-dir.add('example.yaml')) !~~ :f {
37
46
  push @yaml-not-found, $exercise;
38
47
  next;
39
48
  };
40
49
  print "Generating $exercise... ";
41
50
 
42
- my %data = yaml-parse $yaml-file.absolute;
43
-
44
- my $cdata = $base-dir.child("problem-specifications/exercises/$exercise/canonical-data.json");
45
- if $cdata ~~ :f {%data<cdata><json> = $cdata.slurp}
46
-
47
- create-file "$exercise.t", 'test';
48
-
49
- %data<module_file> = %data<example>;
50
- create-file |<Example.pm6 module>;
51
+ given Exercism::Generator.new: :$exercise, data => yaml-parse $yaml-file.absolute {
52
+ given $exercise-dir.add("$exercise.t") -> $testfile {
53
+ $testfile.spurt: .test;
54
+ $testfile.chmod: 0o755;
55
+ }
56
+ $exercise-dir.add('Example.pm6').spurt: .example;
57
+ $exercise-dir.add("{.data<exercise>}.pm6").spurt: .stub;
58
+ }
51
59
 
52
- %data<module_file> = %data<stub>;
53
- create-file "{%data<exercise>}.pm6", 'module';
60
+ given $base-dir.add('bin/configlet') {
61
+ if $_ ~~ :f {
62
+ run .absolute, 'generate', $base-dir, '--only', $exercise;
63
+ }
64
+ }
54
65
 
55
66
  say 'Generated.';
56
-
57
- sub create-file ($filename, $template) {
58
- spurt (my $file = $exercise-dir.child($filename)),
59
- Template::Mustache.render($base-dir.child("templates/$template.mustache").slurp, %data);
60
- $file.chmod(0o755) if $template ~~ 'test';
61
- }
62
67
  }
63
68
 
64
69
  if @dir-not-found {warn 'exercise directory does not exist for: ' ~ join ' ', @dir-not-found}
@@ -0,0 +1,37 @@
1
+ unit class Exercism::Generator;
2
+ use Template::Mustache;
3
+
4
+ my $base-dir = $?FILE.IO.parent.add("../..");
5
+
6
+ has %.data;
7
+ has Str $.exercise;
8
+
9
+ submethod TWEAK {
10
+ if $!exercise && (my $cdata =
11
+ $base-dir.add: "problem-specifications/exercises/$!exercise/canonical-data.json") ~~ :f
12
+ {
13
+ %!data<cdata><json> = $cdata.slurp;
14
+ }
15
+ }
16
+
17
+ method cdata {
18
+ %!data<cdata><json> ?? %!data<cdata><json> !! '';
19
+ }
20
+
21
+ method test {
22
+ self!render(template => 'test');
23
+ }
24
+
25
+ method stub {
26
+ self!render(template => 'module', file => 'stub');
27
+ }
28
+
29
+ method example {
30
+ self!render(template => 'module', file => 'example');
31
+ }
32
+
33
+ method !render (:$template!, :$file) {
34
+ my $data = %!data;
35
+ if $file { $data<module_file> = $data{$file} };
36
+ Template::Mustache.render($base-dir.add("templates/$template.mustache").slurp, $data);
37
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env perl6
2
+ use v6;
3
+ use Test;
4
+ use YAML::Parser::LibYAML;
5
+ use lib (my $base-dir = $?FILE.IO.resolve.parent.parent).add('lib');
6
+ use Exercism::Generator;
7
+
8
+ bail-out if $base-dir.add('problem-specifications') !~~ :d;
9
+ for $base-dir.add('exercises').dir {
10
+ if .add('example.yaml') ~~ :f {
11
+ todo '';
12
+ is .add("{.basename}.t").slurp,
13
+ Exercism::Generator.new(data => yaml-parse(~.add: 'example.yaml'), exercise => .basename).test,
14
+ "{.basename}: test suite matches generated";
15
+ }
16
+ }
17
+
18
+ done-testing;
@@ -25,9 +25,6 @@ Keep your hands off that collect/map/fmap/whatchamacallit functionality
25
25
  provided by your standard library!
26
26
  Solve this one yourself using other basic tools instead.
27
27
 
28
- Lisp specific: it's perfectly fine to use `MAPCAR` or the equivalent,
29
- as this is idiomatic Lisp, not a library function.
30
-
31
28
  ## Advanced
32
29
 
33
30
  It is typical to call [#to_enum](http://ruby-doc.org/core-2.3.1/Object.html#method-i-to_enum) when defining methods for a generic Enumerable, in case no block is passed.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.97
4
+ version: 2.2.1.98
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-20 00:00:00.000000000 Z
11
+ date: 2018-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -9647,7 +9647,7 @@ files:
9647
9647
  - tracks/ocaml/exercises/anagram/example.ml
9648
9648
  - tracks/ocaml/exercises/anagram/test.ml
9649
9649
  - tracks/ocaml/exercises/atbash-cipher/.merlin
9650
- - tracks/ocaml/exercises/atbash-cipher/HINTS.md
9650
+ - tracks/ocaml/exercises/atbash-cipher/.meta/hints.md
9651
9651
  - tracks/ocaml/exercises/atbash-cipher/Makefile
9652
9652
  - tracks/ocaml/exercises/atbash-cipher/README.md
9653
9653
  - tracks/ocaml/exercises/atbash-cipher/atbash_cipher.mli
@@ -9666,7 +9666,7 @@ files:
9666
9666
  - tracks/ocaml/exercises/binary-search/example.ml
9667
9667
  - tracks/ocaml/exercises/binary-search/test.ml
9668
9668
  - tracks/ocaml/exercises/bob/.merlin
9669
- - tracks/ocaml/exercises/bob/HINTS.md
9669
+ - tracks/ocaml/exercises/bob/.meta/hints.md
9670
9670
  - tracks/ocaml/exercises/bob/Makefile
9671
9671
  - tracks/ocaml/exercises/bob/README.md
9672
9672
  - tracks/ocaml/exercises/bob/bob.mli
@@ -10379,6 +10379,8 @@ files:
10379
10379
  - tracks/perl6/exercises/wordy/example.yaml
10380
10380
  - tracks/perl6/exercises/wordy/wordy.t
10381
10381
  - tracks/perl6/img/icon.png
10382
+ - tracks/perl6/lib/Exercism/Generator.pm6
10383
+ - tracks/perl6/t/generated-tests.t
10382
10384
  - tracks/perl6/templates/module.mustache
10383
10385
  - tracks/perl6/templates/test.mustache
10384
10386
  - tracks/php/.editorconfig