trackler 2.0.8.43 → 2.0.8.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon +3 -2
- data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +3 -0
- data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +16 -0
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +16 -0
- data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +1 -0
- data/tracks/ceylon/exercises/react/source/react/ReactorTest.ceylon +2 -0
- data/tracks/ceylon/exercises/sieve/source/sieve/SieveTest.ceylon +1 -0
- data/tracks/crystal/exercises/sieve/src/example.cr +3 -2
- data/tracks/csharp/.github/stale.yml +0 -0
- data/tracks/csharp/exercises/house/HINTS.md +3 -0
- data/tracks/csharp/exercises/saddle-points/HINTS.md +4 -0
- data/tracks/fsharp/.github/stale.yml +0 -0
- data/tracks/go/.github/stale.yml +22 -0
- data/tracks/go/README.md +26 -15
- data/tracks/go/exercises/bob/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/bowling/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/change/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/clock/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/connect/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/custom-set/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/forth/.meta/gen.go +71 -0
- data/tracks/go/exercises/forth/cases_test.go +259 -236
- data/tracks/go/exercises/forth/forth_test.go +19 -34
- data/tracks/go/exercises/gigasecond/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/hamming/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/largest-series-product/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/leap/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/luhn/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/meetup/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/raindrops/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/rna-transcription/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/roman-numerals/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/transpose/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/exercises/word-count/{example_gen.go → .meta/gen.go} +1 -1
- data/tracks/go/gen/gen.go +9 -9
- data/tracks/purescript/config.json +7 -0
- data/tracks/purescript/exercises/binary-search/bower.json +16 -0
- data/tracks/purescript/exercises/binary-search/examples/src/BinarySearch.purs +19 -0
- data/tracks/purescript/exercises/binary-search/src/BinarySearch.purs +3 -0
- data/tracks/purescript/exercises/binary-search/test/Main.purs +53 -0
- data/tracks/python/config.json +6 -0
- data/tracks/python/exercises/rectangles/rectangles_test.py +68 -41
- data/tracks/python/exercises/transpose/example.py +6 -0
- data/tracks/python/exercises/transpose/transpose.py +2 -0
- data/tracks/python/exercises/transpose/transpose_test.py +264 -0
- metadata +32 -20
- data/tracks/go/exercises/forth/example_gen.go +0 -99
@@ -1,246 +1,269 @@
|
|
1
1
|
package forth
|
2
2
|
|
3
3
|
// Source: exercism/x-common
|
4
|
-
// Commit:
|
4
|
+
// Commit: 0d6f5b7 forth: Fix canonical-data.json formatting
|
5
|
+
// x-common version: 1.0.0
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
[]string{},
|
10
|
-
[]int{},
|
11
|
-
},
|
12
|
-
{
|
13
|
-
"numbers just get pushed onto the stack",
|
14
|
-
[]string{"1 2 3 4 5"},
|
15
|
-
[]int{1, 2, 3, 4, 5},
|
16
|
-
},
|
17
|
-
{
|
18
|
-
"all non-word characters are separators",
|
19
|
-
[]string{"1\x002\x133\n4\r5 6\t7"},
|
20
|
-
[]int{1, 2, 3, 4, 5, 6, 7},
|
21
|
-
},
|
22
|
-
}
|
23
|
-
|
24
|
-
var additionGroup = []testCase{
|
25
|
-
{
|
26
|
-
"can add two numbers",
|
27
|
-
[]string{"1 2 +"},
|
28
|
-
[]int{3},
|
29
|
-
},
|
30
|
-
{
|
31
|
-
"errors if there is nothing on the stack",
|
32
|
-
[]string{"+"},
|
33
|
-
[]int(nil),
|
34
|
-
},
|
35
|
-
{
|
36
|
-
"errors if there is only one value on the stack",
|
37
|
-
[]string{"1 +"},
|
38
|
-
[]int(nil),
|
39
|
-
},
|
40
|
-
}
|
41
|
-
|
42
|
-
var subtractionGroup = []testCase{
|
43
|
-
{
|
44
|
-
"can subtract two numbers",
|
45
|
-
[]string{"3 4 -"},
|
46
|
-
[]int{-1},
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"errors if there is nothing on the stack",
|
50
|
-
[]string{"-"},
|
51
|
-
[]int(nil),
|
52
|
-
},
|
53
|
-
{
|
54
|
-
"errors if there is only one value on the stack",
|
55
|
-
[]string{"1 -"},
|
56
|
-
[]int(nil),
|
57
|
-
},
|
58
|
-
}
|
59
|
-
|
60
|
-
var multiplicationGroup = []testCase{
|
61
|
-
{
|
62
|
-
"can multiply two numbers",
|
63
|
-
[]string{"2 4 *"},
|
64
|
-
[]int{8},
|
65
|
-
},
|
66
|
-
{
|
67
|
-
"errors if there is nothing on the stack",
|
68
|
-
[]string{"*"},
|
69
|
-
[]int(nil),
|
70
|
-
},
|
71
|
-
{
|
72
|
-
"errors if there is only one value on the stack",
|
73
|
-
[]string{"1 *"},
|
74
|
-
[]int(nil),
|
75
|
-
},
|
76
|
-
}
|
77
|
-
|
78
|
-
var divisionGroup = []testCase{
|
79
|
-
{
|
80
|
-
"can divide two numbers",
|
81
|
-
[]string{"12 3 /"},
|
82
|
-
[]int{4},
|
83
|
-
},
|
84
|
-
{
|
85
|
-
"performs integer division",
|
86
|
-
[]string{"8 3 /"},
|
87
|
-
[]int{2},
|
88
|
-
},
|
89
|
-
{
|
90
|
-
"errors if dividing by zero",
|
91
|
-
[]string{"4 0 /"},
|
92
|
-
[]int(nil),
|
93
|
-
},
|
94
|
-
{
|
95
|
-
"errors if there is nothing on the stack",
|
96
|
-
[]string{"/"},
|
97
|
-
[]int(nil),
|
98
|
-
},
|
99
|
-
{
|
100
|
-
"errors if there is only one value on the stack",
|
101
|
-
[]string{"1 /"},
|
102
|
-
[]int(nil),
|
103
|
-
},
|
7
|
+
type testGroup struct {
|
8
|
+
group string
|
9
|
+
tests []testCase
|
104
10
|
}
|
105
11
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
[]int{-1},
|
111
|
-
},
|
112
|
-
{
|
113
|
-
"multiplication and division",
|
114
|
-
[]string{"2 4 * 3 /"},
|
115
|
-
[]int{2},
|
116
|
-
},
|
12
|
+
type testCase struct {
|
13
|
+
description string
|
14
|
+
input []string
|
15
|
+
expected []int // nil slice indicates error expected.
|
117
16
|
}
|
118
17
|
|
119
|
-
var
|
120
|
-
{
|
121
|
-
"
|
122
|
-
[]
|
123
|
-
|
18
|
+
var testGroups = []testGroup{
|
19
|
+
{
|
20
|
+
group: "parsing and numbers",
|
21
|
+
tests: []testCase{
|
22
|
+
{
|
23
|
+
"empty input results in empty stack",
|
24
|
+
[]string{},
|
25
|
+
[]int{},
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"numbers just get pushed onto the stack",
|
29
|
+
[]string{"1 2 3 4 5"},
|
30
|
+
[]int{1, 2, 3, 4, 5},
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"all non-word characters are separators",
|
34
|
+
[]string{"1\x002\x133\n4\r5 6\t7"},
|
35
|
+
[]int{1, 2, 3, 4, 5, 6, 7},
|
36
|
+
},
|
37
|
+
},
|
38
|
+
},
|
39
|
+
{
|
40
|
+
group: "addition",
|
41
|
+
tests: []testCase{
|
42
|
+
{
|
43
|
+
"can add two numbers",
|
44
|
+
[]string{"1 2 +"},
|
45
|
+
[]int{3},
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"errors if there is nothing on the stack",
|
49
|
+
[]string{"+"},
|
50
|
+
[]int(nil),
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"errors if there is only one value on the stack",
|
54
|
+
[]string{"1 +"},
|
55
|
+
[]int(nil),
|
56
|
+
},
|
57
|
+
},
|
58
|
+
},
|
59
|
+
{
|
60
|
+
group: "subtraction",
|
61
|
+
tests: []testCase{
|
62
|
+
{
|
63
|
+
"can subtract two numbers",
|
64
|
+
[]string{"3 4 -"},
|
65
|
+
[]int{-1},
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"errors if there is nothing on the stack",
|
69
|
+
[]string{"-"},
|
70
|
+
[]int(nil),
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"errors if there is only one value on the stack",
|
74
|
+
[]string{"1 -"},
|
75
|
+
[]int(nil),
|
76
|
+
},
|
77
|
+
},
|
78
|
+
},
|
79
|
+
{
|
80
|
+
group: "multiplication",
|
81
|
+
tests: []testCase{
|
82
|
+
{
|
83
|
+
"can multiply two numbers",
|
84
|
+
[]string{"2 4 *"},
|
85
|
+
[]int{8},
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"errors if there is nothing on the stack",
|
89
|
+
[]string{"*"},
|
90
|
+
[]int(nil),
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"errors if there is only one value on the stack",
|
94
|
+
[]string{"1 *"},
|
95
|
+
[]int(nil),
|
96
|
+
},
|
97
|
+
},
|
98
|
+
},
|
99
|
+
{
|
100
|
+
group: "division",
|
101
|
+
tests: []testCase{
|
102
|
+
{
|
103
|
+
"can divide two numbers",
|
104
|
+
[]string{"12 3 /"},
|
105
|
+
[]int{4},
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"performs integer division",
|
109
|
+
[]string{"8 3 /"},
|
110
|
+
[]int{2},
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"errors if dividing by zero",
|
114
|
+
[]string{"4 0 /"},
|
115
|
+
[]int(nil),
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"errors if there is nothing on the stack",
|
119
|
+
[]string{"/"},
|
120
|
+
[]int(nil),
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"errors if there is only one value on the stack",
|
124
|
+
[]string{"1 /"},
|
125
|
+
[]int(nil),
|
126
|
+
},
|
127
|
+
},
|
128
|
+
},
|
129
|
+
{
|
130
|
+
group: "combined arithmetic",
|
131
|
+
tests: []testCase{
|
132
|
+
{
|
133
|
+
"addition and subtraction",
|
134
|
+
[]string{"1 2 + 4 -"},
|
135
|
+
[]int{-1},
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"multiplication and division",
|
139
|
+
[]string{"2 4 * 3 /"},
|
140
|
+
[]int{2},
|
141
|
+
},
|
142
|
+
},
|
143
|
+
},
|
144
|
+
{
|
145
|
+
group: "dup",
|
146
|
+
tests: []testCase{
|
147
|
+
{
|
148
|
+
"copies the top value on the stack",
|
149
|
+
[]string{"1 DUP"},
|
150
|
+
[]int{1, 1},
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"is case-insensitive",
|
154
|
+
[]string{"1 2 Dup"},
|
155
|
+
[]int{1, 2, 2},
|
156
|
+
},
|
157
|
+
{
|
158
|
+
"errors if there is nothing on the stack",
|
159
|
+
[]string{"dup"},
|
160
|
+
[]int(nil),
|
161
|
+
},
|
162
|
+
},
|
163
|
+
},
|
164
|
+
{
|
165
|
+
group: "drop",
|
166
|
+
tests: []testCase{
|
167
|
+
{
|
168
|
+
"removes the top value on the stack if it is the only one",
|
169
|
+
[]string{"1 drop"},
|
170
|
+
[]int{},
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"removes the top value on the stack if it is not the only one",
|
174
|
+
[]string{"1 2 drop"},
|
175
|
+
[]int{1},
|
176
|
+
},
|
177
|
+
{
|
178
|
+
"errors if there is nothing on the stack",
|
179
|
+
[]string{"drop"},
|
180
|
+
[]int(nil),
|
181
|
+
},
|
182
|
+
},
|
183
|
+
},
|
184
|
+
{
|
185
|
+
group: "swap",
|
186
|
+
tests: []testCase{
|
187
|
+
{
|
188
|
+
"swaps the top two values on the stack if they are the only ones",
|
189
|
+
[]string{"1 2 swap"},
|
190
|
+
[]int{2, 1},
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"swaps the top two values on the stack if they are not the only ones",
|
194
|
+
[]string{"1 2 3 swap"},
|
195
|
+
[]int{1, 3, 2},
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"errors if there is nothing on the stack",
|
199
|
+
[]string{"swap"},
|
200
|
+
[]int(nil),
|
201
|
+
},
|
202
|
+
{
|
203
|
+
"errors if there is only one value on the stack",
|
204
|
+
[]string{"1 swap"},
|
205
|
+
[]int(nil),
|
206
|
+
},
|
207
|
+
},
|
208
|
+
},
|
209
|
+
{
|
210
|
+
group: "over",
|
211
|
+
tests: []testCase{
|
212
|
+
{
|
213
|
+
"copies the second element if there are only two",
|
214
|
+
[]string{"1 2 over"},
|
215
|
+
[]int{1, 2, 1},
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"copies the second element if there are more than two",
|
219
|
+
[]string{"1 2 3 over"},
|
220
|
+
[]int{1, 2, 3, 2},
|
221
|
+
},
|
222
|
+
{
|
223
|
+
"errors if there is nothing on the stack",
|
224
|
+
[]string{"over"},
|
225
|
+
[]int(nil),
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"errors if there is only one value on the stack",
|
229
|
+
[]string{"1 over"},
|
230
|
+
[]int(nil),
|
231
|
+
},
|
232
|
+
},
|
233
|
+
},
|
234
|
+
{
|
235
|
+
group: "user-defined words",
|
236
|
+
tests: []testCase{
|
237
|
+
{
|
238
|
+
"can consist of built-in words",
|
239
|
+
[]string{": dup-twice dup dup ;", "1 dup-twice"},
|
240
|
+
[]int{1, 1, 1},
|
241
|
+
},
|
242
|
+
{
|
243
|
+
"execute in the right order",
|
244
|
+
[]string{": countup 1 2 3 ;", "countup"},
|
245
|
+
[]int{1, 2, 3},
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"can override other user-defined words",
|
249
|
+
[]string{": foo dup ;", ": foo dup dup ;", "1 foo"},
|
250
|
+
[]int{1, 1, 1},
|
251
|
+
},
|
252
|
+
{
|
253
|
+
"can override built-in words",
|
254
|
+
[]string{": swap dup ;", "1 swap"},
|
255
|
+
[]int{1, 1},
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"cannot redefine numbers",
|
259
|
+
[]string{": 1 2 ;"},
|
260
|
+
[]int(nil),
|
261
|
+
},
|
262
|
+
{
|
263
|
+
"errors if executing a non-existent word",
|
264
|
+
[]string{"foo"},
|
265
|
+
[]int(nil),
|
266
|
+
},
|
267
|
+
},
|
124
268
|
},
|
125
|
-
{
|
126
|
-
"is case-insensitive",
|
127
|
-
[]string{"1 2 Dup"},
|
128
|
-
[]int{1, 2, 2},
|
129
|
-
},
|
130
|
-
{
|
131
|
-
"errors if there is nothing on the stack",
|
132
|
-
[]string{"dup"},
|
133
|
-
[]int(nil),
|
134
|
-
},
|
135
|
-
}
|
136
|
-
|
137
|
-
var dropGroup = []testCase{
|
138
|
-
{
|
139
|
-
"removes the top value on the stack if it is the only one",
|
140
|
-
[]string{"1 drop"},
|
141
|
-
[]int{},
|
142
|
-
},
|
143
|
-
{
|
144
|
-
"removes the top value on the stack if it is not the only one",
|
145
|
-
[]string{"1 2 drop"},
|
146
|
-
[]int{1},
|
147
|
-
},
|
148
|
-
{
|
149
|
-
"errors if there is nothing on the stack",
|
150
|
-
[]string{"drop"},
|
151
|
-
[]int(nil),
|
152
|
-
},
|
153
|
-
}
|
154
|
-
|
155
|
-
var swapGroup = []testCase{
|
156
|
-
{
|
157
|
-
"swaps the top two values on the stack if they are the only ones",
|
158
|
-
[]string{"1 2 swap"},
|
159
|
-
[]int{2, 1},
|
160
|
-
},
|
161
|
-
{
|
162
|
-
"swaps the top two values on the stack if they are not the only ones",
|
163
|
-
[]string{"1 2 3 swap"},
|
164
|
-
[]int{1, 3, 2},
|
165
|
-
},
|
166
|
-
{
|
167
|
-
"errors if there is nothing on the stack",
|
168
|
-
[]string{"swap"},
|
169
|
-
[]int(nil),
|
170
|
-
},
|
171
|
-
{
|
172
|
-
"errors if there is only one value on the stack",
|
173
|
-
[]string{"1 swap"},
|
174
|
-
[]int(nil),
|
175
|
-
},
|
176
|
-
}
|
177
|
-
|
178
|
-
var overGroup = []testCase{
|
179
|
-
{
|
180
|
-
"copies the second element if there are only two",
|
181
|
-
[]string{"1 2 over"},
|
182
|
-
[]int{1, 2, 1},
|
183
|
-
},
|
184
|
-
{
|
185
|
-
"copies the second element if there are more than two",
|
186
|
-
[]string{"1 2 3 over"},
|
187
|
-
[]int{1, 2, 3, 2},
|
188
|
-
},
|
189
|
-
{
|
190
|
-
"errors if there is nothing on the stack",
|
191
|
-
[]string{"over"},
|
192
|
-
[]int(nil),
|
193
|
-
},
|
194
|
-
{
|
195
|
-
"errors if there is only one value on the stack",
|
196
|
-
[]string{"1 over"},
|
197
|
-
[]int(nil),
|
198
|
-
},
|
199
|
-
}
|
200
|
-
|
201
|
-
var userdefinedGroup = []testCase{
|
202
|
-
{
|
203
|
-
"can consist of built-in words",
|
204
|
-
[]string{": dup-twice dup dup ;", "1 dup-twice"},
|
205
|
-
[]int{1, 1, 1},
|
206
|
-
},
|
207
|
-
{
|
208
|
-
"execute in the right order",
|
209
|
-
[]string{": countup 1 2 3 ;", "countup"},
|
210
|
-
[]int{1, 2, 3},
|
211
|
-
},
|
212
|
-
{
|
213
|
-
"can override other user-defined words",
|
214
|
-
[]string{": foo dup ;", ": foo dup dup ;", "1 foo"},
|
215
|
-
[]int{1, 1, 1},
|
216
|
-
},
|
217
|
-
{
|
218
|
-
"can override built-in words",
|
219
|
-
[]string{": swap dup ;", "1 swap"},
|
220
|
-
[]int{1, 1},
|
221
|
-
},
|
222
|
-
{
|
223
|
-
"cannot redefine numbers",
|
224
|
-
[]string{": 1 2 ;"},
|
225
|
-
[]int(nil),
|
226
|
-
},
|
227
|
-
{
|
228
|
-
"errors if executing a non-existent word",
|
229
|
-
[]string{"foo"},
|
230
|
-
[]int(nil),
|
231
|
-
},
|
232
|
-
}
|
233
|
-
|
234
|
-
var testSections = []testcaseSection{
|
235
|
-
{"parsing", parsingGroup},
|
236
|
-
{"addition(+)", additionGroup},
|
237
|
-
{"subtraction(-)", subtractionGroup},
|
238
|
-
{"multiplication(*)", multiplicationGroup},
|
239
|
-
{"division(/)", divisionGroup},
|
240
|
-
{"arithmetic", arithmeticGroup},
|
241
|
-
{"dup", dupGroup},
|
242
|
-
{"drop", dropGroup},
|
243
|
-
{"swap", swapGroup},
|
244
|
-
{"over", overGroup},
|
245
|
-
{"user-defined", userdefinedGroup},
|
246
269
|
}
|
@@ -11,53 +11,38 @@ import (
|
|
11
11
|
|
12
12
|
const targetTestVersion = 1
|
13
13
|
|
14
|
-
type testCase struct {
|
15
|
-
description string
|
16
|
-
input []string
|
17
|
-
expected []int // nil slice indicates error expected.
|
18
|
-
}
|
19
|
-
|
20
|
-
type testcaseSection struct {
|
21
|
-
name string
|
22
|
-
tests []testCase
|
23
|
-
}
|
24
|
-
|
25
14
|
func TestTestVersion(t *testing.T) {
|
26
15
|
if testVersion != targetTestVersion {
|
27
16
|
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
28
17
|
}
|
29
18
|
}
|
30
19
|
|
31
|
-
func
|
32
|
-
for _,
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
20
|
+
func TestForth(t *testing.T) {
|
21
|
+
for _, tg := range testGroups {
|
22
|
+
for _, tc := range tg.tests {
|
23
|
+
if v, err := Forth(tc.input); err == nil {
|
24
|
+
var _ error = err
|
25
|
+
if tc.expected == nil {
|
26
|
+
t.Fatalf("FAIL: %s | %s\n\tForth(%#v) expected an error, got %v",
|
27
|
+
tg.group, tc.description, tc.input, v)
|
28
|
+
} else if !reflect.DeepEqual(v, tc.expected) {
|
29
|
+
t.Fatalf("FAIL: %s | %s\n\tForth(%#v) expected %v, got %v",
|
30
|
+
tg.group, tc.description, tc.input, tc.expected, v)
|
31
|
+
}
|
32
|
+
} else if tc.expected != nil {
|
33
|
+
t.Fatalf("FAIL: %s | %s\n\tForth(%#v) expected %v, got an error: %q",
|
34
|
+
tg.group, tc.description, tc.input, tc.expected, err)
|
42
35
|
}
|
43
|
-
|
44
|
-
t.Fatalf("%s\n\tForth(%#v) expected %v, got an error: %q",
|
45
|
-
description, tc.input, tc.expected, err)
|
36
|
+
t.Logf("PASS: %s | %s", tg.group, tc.description)
|
46
37
|
}
|
47
38
|
}
|
48
39
|
}
|
49
40
|
|
50
|
-
func TestForth(t *testing.T) {
|
51
|
-
for _, testSection := range testSections {
|
52
|
-
runTestCases(t, testSection.name, testSection.tests)
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
41
|
func BenchmarkForth(b *testing.B) {
|
57
42
|
for i := 0; i < b.N; i++ {
|
58
|
-
for _,
|
59
|
-
for _,
|
60
|
-
Forth(
|
43
|
+
for _, tg := range testGroups {
|
44
|
+
for _, tc := range tg.tests {
|
45
|
+
Forth(tc.input)
|
61
46
|
}
|
62
47
|
}
|
63
48
|
}
|