trackler 2.0.1.1 → 2.0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/update +4 -0
- data/common/exercises/minesweeper/canonical-data.json +3 -3
- data/fixtures/common/exercises/imbe/description.md +2 -0
- data/fixtures/common/exercises/imbe/metadata.yml +3 -0
- data/fixtures/common/exercises/no-metadata/description.md +1 -0
- data/fixtures/tracks/fruit/exercises/imbe/.meta/everything_in_meta_is_ignored.txt +0 -0
- data/fixtures/tracks/fruit/exercises/imbe/CaSe_iNSeNSiTiVe_eXaMPLe.TXT +0 -0
- data/fixtures/tracks/fruit/exercises/imbe/HINTS.md +1 -0
- data/fixtures/tracks/fruit/exercises/imbe/also_an_example.txt +1 -0
- data/fixtures/tracks/fruit/exercises/imbe/example.ext +1 -0
- data/fixtures/tracks/fruit/exercises/imbe/imbe.txt +1 -0
- data/lib/trackler/file_bundle.rb +27 -9
- data/lib/trackler/implementation.rb +7 -6
- data/lib/trackler/problem.rb +62 -37
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/config.json +9 -0
- data/tracks/c/exercises/series/makefile +16 -0
- data/tracks/c/exercises/series/src/example.c +24 -0
- data/tracks/c/exercises/series/src/series.h +28 -0
- data/tracks/c/exercises/series/test/test_series.c +63 -0
- data/tracks/c/exercises/series/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/series/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/series/test/vendor/unity_internals.h +701 -0
- data/tracks/crystal/src/generator/exercises/binary.cr +3 -3
- data/tracks/crystal/src/generator/exercises/forth.cr +3 -3
- data/tracks/crystal/src/generator/exercises/hello_world.cr +1 -1
- data/tracks/haskell/exercises/bob/test/Tests.hs +2 -10
- data/tracks/haskell/exercises/sublist/test/Tests.hs +6 -1
- data/tracks/java/config.json +13 -1
- data/tracks/java/exercises/bracket-push/build.gradle +17 -0
- data/tracks/java/exercises/bracket-push/src/example/java/BracketChecker.java +45 -0
- data/tracks/java/exercises/bracket-push/src/main/java/BracketChecker.java +5 -0
- data/tracks/java/exercises/bracket-push/src/test/java/BracketCheckerTest.java +102 -0
- data/tracks/java/exercises/robot-simulator/build.gradle +17 -0
- data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +1 -0
- data/tracks/java/exercises/robot-simulator/src/example/java/Orientation.java +1 -0
- data/tracks/java/exercises/robot-simulator/src/example/java/Robot.java +71 -0
- data/tracks/java/exercises/robot-simulator/src/main/java/GridPosition.java +29 -0
- data/tracks/java/exercises/robot-simulator/src/main/java/Orientation.java +5 -0
- data/tracks/java/exercises/robot-simulator/src/main/java/Robot.java +5 -0
- data/tracks/java/exercises/robot-simulator/src/test/java/RobotTest.java +244 -0
- data/tracks/java/exercises/settings.gradle +2 -0
- data/tracks/ocaml/exercises/say/test.ml +52 -56
- data/tracks/ocaml/tools/test-generator/src/codegen.ml +2 -1
- data/tracks/ocaml/tools/test-generator/src/special_cases.ml +10 -4
- data/tracks/ocaml/tools/test-generator/src/test_generator.ml +5 -0
- data/tracks/ocaml/tools/test-generator/templates/say/template.ml +21 -0
- data/tracks/ocaml/tools/test-generator/test/special_cases_test.ml +2 -2
- metadata +30 -1
@@ -0,0 +1,244 @@
|
|
1
|
+
import org.junit.Ignore;
|
2
|
+
import org.junit.Test;
|
3
|
+
|
4
|
+
import static org.junit.Assert.assertTrue;
|
5
|
+
|
6
|
+
public final class RobotTest {
|
7
|
+
|
8
|
+
@Test
|
9
|
+
public void testRobotIsCreatedWithCorrectInitialPosition() {
|
10
|
+
final GridPosition initialGridPosition = new GridPosition(0, 0);
|
11
|
+
final Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
12
|
+
|
13
|
+
assertTrue(robot.getGridPosition().equals(initialGridPosition));
|
14
|
+
}
|
15
|
+
|
16
|
+
@Ignore
|
17
|
+
@Test
|
18
|
+
public void testRobotIsCreatedWithCorrectInitialOrientation() {
|
19
|
+
final Orientation initialOrientation = Orientation.NORTH;
|
20
|
+
final Robot robot = new Robot(new GridPosition(0, 0), initialOrientation);
|
21
|
+
|
22
|
+
assertTrue(robot.getOrientation().equals(initialOrientation));
|
23
|
+
}
|
24
|
+
|
25
|
+
@Ignore
|
26
|
+
@Test
|
27
|
+
public void testTurningRightDoesNotChangePosition() {
|
28
|
+
final GridPosition initialGridPosition = new GridPosition(0, 0);
|
29
|
+
final Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
30
|
+
|
31
|
+
robot.turnRight();
|
32
|
+
|
33
|
+
assertTrue(robot.getGridPosition().equals(initialGridPosition));
|
34
|
+
}
|
35
|
+
|
36
|
+
@Ignore
|
37
|
+
@Test
|
38
|
+
public void testTurningRightCorrectlyChangesOrientationFromNorthToEast() {
|
39
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
40
|
+
|
41
|
+
robot.turnRight();
|
42
|
+
|
43
|
+
final Orientation expectedOrientation = Orientation.EAST;
|
44
|
+
|
45
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
46
|
+
}
|
47
|
+
|
48
|
+
@Ignore
|
49
|
+
@Test
|
50
|
+
public void testTurningRightCorrectlyChangesOrientationFromEastToSouth() {
|
51
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
52
|
+
|
53
|
+
robot.turnRight();
|
54
|
+
|
55
|
+
final Orientation expectedOrientation = Orientation.SOUTH;
|
56
|
+
|
57
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
58
|
+
}
|
59
|
+
|
60
|
+
@Ignore
|
61
|
+
@Test
|
62
|
+
public void testTurningRightCorrectlyChangesOrientationFromSouthToWest() {
|
63
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
64
|
+
|
65
|
+
robot.turnRight();
|
66
|
+
|
67
|
+
final Orientation expectedOrientation = Orientation.WEST;
|
68
|
+
|
69
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
70
|
+
}
|
71
|
+
|
72
|
+
@Ignore
|
73
|
+
@Test
|
74
|
+
public void testTurningRightCorrectlyChangesOrientationFromWestToNorth() {
|
75
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
76
|
+
|
77
|
+
robot.turnRight();
|
78
|
+
|
79
|
+
final Orientation expectedOrientation = Orientation.NORTH;
|
80
|
+
|
81
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
82
|
+
}
|
83
|
+
|
84
|
+
@Ignore
|
85
|
+
@Test
|
86
|
+
public void testTurningLeftDoesNotChangePosition() {
|
87
|
+
final GridPosition initialGridPosition = new GridPosition(0, 0);
|
88
|
+
final Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
89
|
+
|
90
|
+
robot.turnLeft();
|
91
|
+
|
92
|
+
assertTrue(robot.getGridPosition().equals(initialGridPosition));
|
93
|
+
}
|
94
|
+
|
95
|
+
@Ignore
|
96
|
+
@Test
|
97
|
+
public void testTurningLeftCorrectlyChangesOrientationFromNorthToWest() {
|
98
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
99
|
+
|
100
|
+
robot.turnLeft();
|
101
|
+
|
102
|
+
final Orientation expectedOrientation = Orientation.WEST;
|
103
|
+
|
104
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
105
|
+
}
|
106
|
+
|
107
|
+
@Ignore
|
108
|
+
@Test
|
109
|
+
public void testTurningLeftCorrectlyChangesOrientationFromWestToSouth() {
|
110
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
111
|
+
|
112
|
+
robot.turnLeft();
|
113
|
+
|
114
|
+
final Orientation expectedOrientation = Orientation.SOUTH;
|
115
|
+
|
116
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
117
|
+
}
|
118
|
+
|
119
|
+
@Ignore
|
120
|
+
@Test
|
121
|
+
public void testTurningLeftCorrectlyChangesOrientationFromSouthToEast() {
|
122
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
123
|
+
|
124
|
+
robot.turnLeft();
|
125
|
+
|
126
|
+
final Orientation expectedOrientation = Orientation.EAST;
|
127
|
+
|
128
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
129
|
+
}
|
130
|
+
|
131
|
+
@Ignore
|
132
|
+
@Test
|
133
|
+
public void testTurningLeftCorrectlyChangesOrientationFromEastToNorth() {
|
134
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
135
|
+
|
136
|
+
robot.turnLeft();
|
137
|
+
|
138
|
+
final Orientation expectedOrientation = Orientation.NORTH;
|
139
|
+
|
140
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
141
|
+
}
|
142
|
+
|
143
|
+
@Ignore
|
144
|
+
@Test
|
145
|
+
public void testAdvancingDoesNotChangeOrientation() {
|
146
|
+
final Orientation initialOrientation = Orientation.NORTH;
|
147
|
+
final Robot robot = new Robot(new GridPosition(0, 0), initialOrientation);
|
148
|
+
|
149
|
+
robot.advance();
|
150
|
+
|
151
|
+
assertTrue(robot.getOrientation().equals(initialOrientation));
|
152
|
+
}
|
153
|
+
|
154
|
+
@Ignore
|
155
|
+
@Test
|
156
|
+
public void testAdvancingWhenFacingNorthIncreasesYCoordinateByOne() {
|
157
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
158
|
+
|
159
|
+
robot.advance();
|
160
|
+
|
161
|
+
final GridPosition expectedGridPosition = new GridPosition(0, 1);
|
162
|
+
|
163
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
164
|
+
}
|
165
|
+
|
166
|
+
@Ignore
|
167
|
+
@Test
|
168
|
+
public void testAdvancingWhenFacingSouthDecreasesYCoordinateByOne() {
|
169
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
170
|
+
|
171
|
+
robot.advance();
|
172
|
+
|
173
|
+
final GridPosition expectedGridPosition = new GridPosition(0, -1);
|
174
|
+
|
175
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
176
|
+
}
|
177
|
+
|
178
|
+
@Ignore
|
179
|
+
@Test
|
180
|
+
public void testAdvancingWhenFacingEastIncreasesXCoordinateByOne() {
|
181
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
182
|
+
|
183
|
+
robot.advance();
|
184
|
+
|
185
|
+
final GridPosition expectedGridPosition = new GridPosition(1, 0);
|
186
|
+
|
187
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
188
|
+
}
|
189
|
+
|
190
|
+
@Ignore
|
191
|
+
@Test
|
192
|
+
public void testAdvancingWhenFacingWestDecreasesXCoordinateByOne() {
|
193
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
194
|
+
|
195
|
+
robot.advance();
|
196
|
+
|
197
|
+
final GridPosition expectedGridPosition = new GridPosition(-1, 0);
|
198
|
+
|
199
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
200
|
+
}
|
201
|
+
|
202
|
+
@Ignore
|
203
|
+
@Test
|
204
|
+
public void testInstructionsToMoveWestAndNorth() {
|
205
|
+
final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
206
|
+
|
207
|
+
robot.simulate("LAAARALA");
|
208
|
+
|
209
|
+
final GridPosition expectedGridPosition = new GridPosition(-4, 1);
|
210
|
+
final Orientation expectedOrientation = Orientation.WEST;
|
211
|
+
|
212
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
213
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
214
|
+
}
|
215
|
+
|
216
|
+
@Ignore
|
217
|
+
@Test
|
218
|
+
public void testInstructionsToMoveWestAndSouth() {
|
219
|
+
final Robot robot = new Robot(new GridPosition(2, -7), Orientation.EAST);
|
220
|
+
|
221
|
+
robot.simulate("RRAAAAALA");
|
222
|
+
|
223
|
+
final GridPosition expectedGridPosition = new GridPosition(-3, -8);
|
224
|
+
final Orientation expectedOrientation = Orientation.SOUTH;
|
225
|
+
|
226
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
227
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
228
|
+
}
|
229
|
+
|
230
|
+
@Ignore
|
231
|
+
@Test
|
232
|
+
public void testInstructionsToMoveEastAndNorth() {
|
233
|
+
final Robot robot = new Robot(new GridPosition(8, 4), Orientation.SOUTH);
|
234
|
+
|
235
|
+
robot.simulate("LAAARRRALLLL");
|
236
|
+
|
237
|
+
final GridPosition expectedGridPosition = new GridPosition(11, 5);
|
238
|
+
final Orientation expectedOrientation = Orientation.NORTH;
|
239
|
+
|
240
|
+
assertTrue(robot.getGridPosition().equals(expectedGridPosition));
|
241
|
+
assertTrue(robot.getOrientation().equals(expectedOrientation));
|
242
|
+
}
|
243
|
+
|
244
|
+
}
|
@@ -6,6 +6,7 @@ include 'atbash-cipher'
|
|
6
6
|
include 'beer-song'
|
7
7
|
include 'binary'
|
8
8
|
include 'bob'
|
9
|
+
include 'bracket-push'
|
9
10
|
include 'crypto-square'
|
10
11
|
include 'difference-of-squares'
|
11
12
|
include 'etl'
|
@@ -30,6 +31,7 @@ include 'queen-attack'
|
|
30
31
|
include 'raindrops'
|
31
32
|
include 'rna-transcription'
|
32
33
|
include 'robot-name'
|
34
|
+
include 'robot-simulator'
|
33
35
|
include 'roman-numerals'
|
34
36
|
include 'prime-factors'
|
35
37
|
include 'scrabble-score'
|
@@ -2,64 +2,60 @@ open Core.Std
|
|
2
2
|
open OUnit2
|
3
3
|
open Say
|
4
4
|
|
5
|
-
|
6
|
-
boilerplate. *)
|
7
|
-
let say_test exp n =
|
8
|
-
exp>::(fun _ctx ->
|
9
|
-
assert_equal ~printer:(Option.value ~default:"None")
|
10
|
-
(Some exp) (in_english n))
|
5
|
+
let ae exp got _ctx = assert_equal ~printer:(Option.value ~default:"None") exp got
|
11
6
|
|
12
7
|
let tests = [
|
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
|
-
|
8
|
+
"zero" >:: (
|
9
|
+
ae (Some "zero")
|
10
|
+
(in_english 0L));
|
11
|
+
"one" >:: (
|
12
|
+
ae (Some "one")
|
13
|
+
(in_english 1L));
|
14
|
+
"fourteen" >:: (
|
15
|
+
ae (Some "fourteen")
|
16
|
+
(in_english 14L));
|
17
|
+
"twenty" >:: (
|
18
|
+
ae (Some "twenty")
|
19
|
+
(in_english 20L));
|
20
|
+
"twenty-two" >:: (
|
21
|
+
ae (Some "twenty-two")
|
22
|
+
(in_english 22L));
|
23
|
+
"one hundred" >:: (
|
24
|
+
ae (Some "one hundred")
|
25
|
+
(in_english 100L));
|
26
|
+
"one hundred twenty-three" >:: (
|
27
|
+
ae (Some "one hundred twenty-three")
|
28
|
+
(in_english 123L));
|
29
|
+
"one thousand" >:: (
|
30
|
+
ae (Some "one thousand")
|
31
|
+
(in_english 1000L));
|
32
|
+
"one thousand two hundred thirty-four" >:: (
|
33
|
+
ae (Some "one thousand two hundred thirty-four")
|
34
|
+
(in_english 1234L));
|
35
|
+
"one million" >:: (
|
36
|
+
ae (Some "one million")
|
37
|
+
(in_english 1000000L));
|
38
|
+
"one million two thousand three hundred forty-five" >:: (
|
39
|
+
ae (Some "one million two thousand three hundred forty-five")
|
40
|
+
(in_english 1002345L));
|
41
|
+
"one billion" >:: (
|
42
|
+
ae (Some "one billion")
|
43
|
+
(in_english 1000000000L));
|
44
|
+
"a big number" >:: (
|
45
|
+
ae (Some "nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three")
|
46
|
+
(in_english 987654321123L));
|
47
|
+
"numbers below zero are out of range" >:: (
|
48
|
+
ae None
|
49
|
+
(in_english (-1L)));
|
50
|
+
"numbers above 999,999,999,999 are out of range" >:: (
|
51
|
+
ae None
|
52
|
+
(in_english 1000000000000L));
|
57
53
|
"all numbers from 1 to 10_000 can be spelt">::(fun _ ->
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
assert_bool "range test" (Sequence.range 0 10_000
|
55
|
+
|> Sequence.map ~f:(fun n -> Int64.of_int n |> in_english)
|
56
|
+
|> Sequence.filter ~f:(Option.is_none)
|
57
|
+
|> Sequence.is_empty));
|
58
|
+
]
|
63
59
|
|
64
60
|
let () =
|
65
|
-
run_test_tt_main ("say tests" >::: tests)
|
61
|
+
run_test_tt_main ("say tests" >::: tests)
|
@@ -11,7 +11,8 @@ type subst = Subst of string [@@deriving eq, show]
|
|
11
11
|
let subst_to_string (Subst s) = s
|
12
12
|
|
13
13
|
let replace_key (key: string) (value: string) (target: string): string =
|
14
|
-
String.substr_replace_all ~
|
14
|
+
let replace = String.substr_replace_all ~with_:value in
|
15
|
+
replace ~pattern:("$" ^ key) target |> replace ~pattern:("$(" ^ key ^ ")")
|
15
16
|
|
16
17
|
let rec replace_keys (f: fixup_parameter_function) (ed: edit_parameters_function) (s: string) (c: case): subst =
|
17
18
|
let s = replace_key "description" c.description s in
|
@@ -5,14 +5,19 @@ open Model
|
|
5
5
|
let optional_int ~(none: int) = function
|
6
6
|
| Int n when n = none -> "None"
|
7
7
|
| Int n -> "(Some " ^ Int.to_string n ^ ")"
|
8
|
-
|
|
8
|
+
| x -> parameter_to_string x
|
9
|
+
|
10
|
+
let optional_int_or_string ~(none: int) = function
|
11
|
+
| String s -> "(Some \"" ^ s ^ "\")"
|
12
|
+
| Int n when n = none -> "None"
|
13
|
+
| x -> parameter_to_string x
|
9
14
|
|
10
15
|
let default_value ~(key: string) ~(value: string) (parameters: (string * string) list): (string * string) list =
|
11
16
|
if List.exists ~f:(fun (k, _) -> k = key) parameters
|
12
17
|
then parameters
|
13
18
|
else (key, value) :: parameters
|
14
19
|
|
15
|
-
let
|
20
|
+
let optional_strings ~(f: string -> bool) (parameters: (string * string) list): (string * string) list =
|
16
21
|
let replace parameter =
|
17
22
|
let (k, v) = parameter in
|
18
23
|
if f k
|
@@ -21,11 +26,12 @@ let optional_string ~(f: string -> bool) (parameters: (string * string) list): (
|
|
21
26
|
List.map ~f:replace parameters
|
22
27
|
|
23
28
|
let fixup ~(stringify: parameter -> string) ~(slug: string) ~(key: string) ~(value: parameter) = match (slug, key) with
|
24
|
-
| ("hamming", "expected") -> optional_int (-1) value
|
29
|
+
| ("hamming", "expected") -> optional_int ~none:(-1) value
|
30
|
+
| ("say", "expected") -> optional_int_or_string ~none:(-1) value
|
25
31
|
| _ -> stringify value
|
26
32
|
|
27
33
|
let edit ~(slug: string) (parameters: (string * string) list) = match (slug, parameters) with
|
28
34
|
| ("hello-world", ps) -> default_value ~key:"name" ~value:"None"
|
29
|
-
@@
|
35
|
+
@@ optional_strings ~f:(fun _x -> true)
|
30
36
|
@@ parameters
|
31
37
|
| (_, ps) -> ps
|
@@ -32,10 +32,15 @@ let generate_code ~slug ~template_file ~canonical_data_file =
|
|
32
32
|
let substs = Result.ok_or_failwith @@ generate_code (fixup ~stringify:parameter_to_string ~slug) (edit ~slug) template.template cs in
|
33
33
|
Result.return (fill template substs)
|
34
34
|
|
35
|
+
(* Hack - right now it's generating -1L, but Ocaml needs (-1L) *)
|
36
|
+
let final_fixup (s: string): string =
|
37
|
+
String.substr_replace_all s ~pattern:"-1L" ~with_:"(-1L)"
|
38
|
+
|
35
39
|
let output_tests (files: (string * content * content) list) (output_folder: string): unit =
|
36
40
|
let output_filepath name = output_folder ^ "/" ^ name ^ "/test.ml" in
|
37
41
|
let output1 (slug,t,c) =
|
38
42
|
let code = Result.ok_or_failwith @@ generate_code slug t c in
|
43
|
+
let code = final_fixup code in
|
39
44
|
Out_channel.write_all (output_filepath slug) code in
|
40
45
|
List.iter files ~f:output1
|
41
46
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
open Core.Std
|
2
|
+
open OUnit2
|
3
|
+
open Say
|
4
|
+
|
5
|
+
let ae exp got _ctx = assert_equal ~printer:(Option.value ~default:"None") exp got
|
6
|
+
|
7
|
+
let tests = [
|
8
|
+
(* GENERATED-CODE
|
9
|
+
"$description" >:: (
|
10
|
+
ae $expected
|
11
|
+
(in_english $(input)L));
|
12
|
+
END GENERATED-CODE *)
|
13
|
+
"all numbers from 1 to 10_000 can be spelt">::(fun _ ->
|
14
|
+
assert_bool "range test" (Sequence.range 0 10_000
|
15
|
+
|> Sequence.map ~f:(fun n -> Int64.of_int n |> in_english)
|
16
|
+
|> Sequence.filter ~f:(Option.is_none)
|
17
|
+
|> Sequence.is_empty));
|
18
|
+
]
|
19
|
+
|
20
|
+
let () =
|
21
|
+
run_test_tt_main ("say tests" >::: tests)
|