Skip to content

Commit 2b52e24

Browse files
committed
🚧 test generator
1 parent 4d3e2d2 commit 2b52e24

File tree

13 files changed

+612
-43
lines changed

13 files changed

+612
-43
lines changed

.devcontainer/devcontainer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/universal:2",
3+
"features": {
4+
"ghcr.io/devcontainers/features/php:1": {
5+
"version": "8.3",
6+
"installComposer": true
7+
}
8+
}
9+
}

exercises/practice/list-ops/ListOpsTest.php

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function setUpBeforeClass(): void
3636
/**
3737
* @testdox append entries to a list and return the new list -> empty lists
3838
*/
39-
public function testAppendEmptyLists()
39+
public function testAppendEntriesToAListAndReturnTheNewListWithEmptyLists()
4040
{
4141
$listOps = new ListOps();
4242
$this->assertEquals([], $listOps->append([], []));
@@ -45,25 +45,25 @@ public function testAppendEmptyLists()
4545
/**
4646
* @testdox append entries to a list and return the new list -> list to empty list
4747
*/
48-
public function testAppendNonEmptyListToEmptyList()
48+
public function testAppendEntriesToAListAndReturnTheNewListWithListToEmptyList()
4949
{
5050
$listOps = new ListOps();
51-
$this->assertEquals([1, 2, 3, 4], $listOps->append([1, 2, 3, 4], []));
51+
$this->assertEquals([1, 2, 3, 4], $listOps->append([], [1, 2, 3, 4]));
5252
}
5353

5454
/**
5555
* @testdox append entries to a list and return the new list -> empty list to list
5656
*/
57-
public function testAppendEmptyListToNonEmptyList()
57+
public function testAppendEntriesToAListAndReturnTheNewListWithEmptyListToList()
5858
{
5959
$listOps = new ListOps();
60-
$this->assertEquals([1, 2, 3, 4], $listOps->append([], [1, 2, 3, 4]));
60+
$this->assertEquals([1, 2, 3, 4], $listOps->append([1, 2, 3, 4], []));
6161
}
6262

6363
/**
6464
* @testdox append entries to a list and return the new list -> non-empty lists
6565
*/
66-
public function testAppendNonEmptyLists()
66+
public function testAppendEntriesToAListAndReturnTheNewListWithNonEmptyLists()
6767
{
6868
$listOps = new ListOps();
6969
$this->assertEquals([1, 2, 2, 3, 4, 5], $listOps->append([1, 2], [2, 3, 4, 5]));
@@ -72,16 +72,16 @@ public function testAppendNonEmptyLists()
7272
/**
7373
* @testdox concatenate a list of lists -> empty list
7474
*/
75-
public function testConcatEmptyLists()
75+
public function testConcatenateAListOfListsWithEmptyList()
7676
{
7777
$listOps = new ListOps();
78-
$this->assertEquals([], $listOps->concat([], []));
78+
$this->assertEquals([], $listOps->concat());
7979
}
8080

8181
/**
8282
* @testdox concatenate a list of lists -> list of lists
8383
*/
84-
public function testConcatLists()
84+
public function testConcatenateAListOfListsWithListOfLists()
8585
{
8686
$listOps = new ListOps();
8787
$this->assertEquals([1, 2, 3, 4, 5, 6], $listOps->concat([1, 2], [3], [], [4, 5, 6]));
@@ -90,7 +90,7 @@ public function testConcatLists()
9090
/**
9191
* @testdox concatenate a list of lists -> list of nested lists
9292
*/
93-
public function testConcatNestedLists()
93+
public function testConcatenateAListOfListsWithListOfNestedLists()
9494
{
9595
$listOps = new ListOps();
9696
$this->assertEquals([[1], [2], [3], [], [4, 5, 6]], $listOps->concat([[1], [2]], [[3]], [[]], [[4, 5, 6]]));
@@ -99,7 +99,7 @@ public function testConcatNestedLists()
9999
/**
100100
* @testdox filter list returning only values that satisfy the filter function -> empty list
101101
*/
102-
public function testFilterEmptyList()
102+
public function testFilterListReturningOnlyValuesThatSatisfyTheFilterFunctionWithEmptyList()
103103
{
104104
$listOps = new ListOps();
105105
$this->assertEquals(
@@ -109,9 +109,9 @@ public function testFilterEmptyList()
109109
}
110110

111111
/**
112-
* @testdox filter list returning only values that satisfy the filter function -> non empty list
112+
* @testdox filter list returning only values that satisfy the filter function -> non-empty list
113113
*/
114-
public function testFilterNonEmptyList()
114+
public function testFilterListReturningOnlyValuesThatSatisfyTheFilterFunctionWithNonEmptyList()
115115
{
116116
$listOps = new ListOps();
117117
$this->assertEquals(
@@ -123,7 +123,7 @@ public function testFilterNonEmptyList()
123123
/**
124124
* @testdox returns the length of a list -> empty list
125125
*/
126-
public function testLengthEmptyList()
126+
public function testReturnsTheLengthOfAListWithEmptyList()
127127
{
128128
$listOps = new ListOps();
129129
$this->assertEquals(0, $listOps->length([]));
@@ -132,16 +132,16 @@ public function testLengthEmptyList()
132132
/**
133133
* @testdox returns the length of a list -> non-empty list
134134
*/
135-
public function testLengthNonEmptyList()
135+
public function testReturnsTheLengthOfAListWithNonEmptyList()
136136
{
137137
$listOps = new ListOps();
138138
$this->assertEquals(4, $listOps->length([1, 2, 3, 4]));
139139
}
140140

141141
/**
142-
* @testdox returns a list of elements whose values equal the list value transformed by the mapping function -> empty list
142+
* @testdox return a list of elements whose values equal the list value transformed by the mapping function -> empty list
143143
*/
144-
public function testMapEmptyList()
144+
public function testReturnAListOfElementsWhoseValuesEqualTheListValueTransformedByTheMappingFunctionWithEmptyList()
145145
{
146146
$listOps = new ListOps();
147147
$this->assertEquals(
@@ -151,9 +151,9 @@ public function testMapEmptyList()
151151
}
152152

153153
/**
154-
* @testdox returns a list of elements whose values equal the list value transformed by the mapping function -> non-empty list
154+
* @testdox return a list of elements whose values equal the list value transformed by the mapping function -> non-empty list
155155
*/
156-
public function testMapNonEmptyList()
156+
public function testReturnAListOfElementsWhoseValuesEqualTheListValueTransformedByTheMappingFunctionWithNonEmptyList()
157157
{
158158
$listOps = new ListOps();
159159
$this->assertEquals(
@@ -165,7 +165,7 @@ public function testMapNonEmptyList()
165165
/**
166166
* @testdox folds (reduces) the given list from the left with a function -> empty list
167167
*/
168-
public function testFoldlEmptyList()
168+
public function testFoldsReducesTheGivenListFromTheLeftWithAFunctionWithEmptyList()
169169
{
170170
$listOps = new ListOps();
171171
$this->assertEquals(
@@ -177,19 +177,19 @@ public function testFoldlEmptyList()
177177
/**
178178
* @testdox folds (reduces) the given list from the left with a function -> direction independent function applied to non-empty list
179179
*/
180-
public function testFoldlDirectionIndependentNonEmptyList()
180+
public function testFoldsReducesTheGivenListFromTheLeftWithAFunctionWithDirectionIndependentFunctionAppliedToNonEmptyList()
181181
{
182182
$listOps = new ListOps();
183183
$this->assertEquals(
184184
15,
185-
$listOps->foldl(static fn ($acc, $el) => $acc + $el, [1, 2, 3, 4], 5)
185+
$listOps->foldl(static fn ($acc, $el) => $el + $acc, [1, 2, 3, 4], 5)
186186
);
187187
}
188188

189189
/**
190190
* @testdox folds (reduces) the given list from the left with a function -> direction dependent function applied to non-empty list
191191
*/
192-
public function testFoldlDirectionDependentNonEmptyList()
192+
public function testFoldsReducesTheGivenListFromTheLeftWithAFunctionWithDirectionDependentFunctionAppliedToNonEmptyList()
193193
{
194194
$listOps = new ListOps();
195195
$this->assertEquals(
@@ -201,61 +201,54 @@ public function testFoldlDirectionDependentNonEmptyList()
201201
/**
202202
* @testdox folds (reduces) the given list from the right with a function -> empty list
203203
*/
204-
public function testFoldrEmptyList()
204+
public function testFoldsReducesTheGivenListFromTheRightWithAFunctionWithEmptyList()
205205
{
206206
$listOps = new ListOps();
207207
$this->assertEquals(
208208
2,
209209
$listOps->foldr(static fn ($acc, $el) => $el * $acc, [], 2)
210210
);
211211
}
212-
213212
/**
214213
* @testdox folds (reduces) the given list from the right with a function -> direction independent function applied to non-empty list
215214
*/
216-
public function testFoldrDirectionIndependentNonEmptyList()
215+
public function testFoldsReducesTheGivenListFromTheRightWithAFunctionWithDirectionIndependentFunctionAppliedToNonEmptyList()
217216
{
218217
$listOps = new ListOps();
219218
$this->assertEquals(
220219
15,
221-
$listOps->foldr(static fn ($acc, $el) => $acc + $el, [1, 2, 3, 4], 5)
220+
$listOps->foldr(static fn ($acc, $el) => $el + $acc, [1, 2, 3, 4], 5)
222221
);
223222
}
224-
225223
/**
226224
* @testdox folds (reduces) the given list from the right with a function -> direction dependent function applied to non-empty list
227225
*/
228-
public function testFoldrDirectionDependentNonEmptyList()
226+
public function testFoldsReducesTheGivenListFromTheRightWithAFunctionWithDirectionDependentFunctionAppliedToNonEmptyList()
229227
{
230228
$listOps = new ListOps();
231229
$this->assertEquals(
232230
9,
233231
$listOps->foldr(static fn ($acc, $el) => $el / $acc, [1, 2, 3, 4], 24)
234232
);
235233
}
236-
237-
/**
238-
* @testdox reverse the elements of a list -> empty list
234+
/**
235+
* @testdox reverse the elements of the list -> empty list
239236
*/
240-
public function testReverseEmptyList()
237+
public function testReverseTheElementsOfTheListWithEmptyList()
241238
{
242239
$listOps = new ListOps();
243240
$this->assertEquals([], $listOps->reverse([]));
244-
}
245-
246-
/**
247-
* @testdox reverse the elements of a list -> non-empty list
241+
} /**
242+
* @testdox reverse the elements of the list -> non-empty list
248243
*/
249-
public function testReverseNonEmptyList()
244+
public function testReverseTheElementsOfTheListWithNonEmptyList()
250245
{
251246
$listOps = new ListOps();
252247
$this->assertEquals([7, 5, 3, 1], $listOps->reverse([1, 3, 5, 7]));
253-
}
254-
255-
/**
256-
* @testdox reverse the elements of a list -> list of lists is not flattened
248+
} /**
249+
* @testdox reverse the elements of the list -> list of lists is not flattened
257250
*/
258-
public function testReverseNonEmptyListIsNotFlattened()
251+
public function testReverseTheElementsOfTheListWithListOfListsIsNotFlattened()
259252
{
260253
$listOps = new ListOps();
261254
$this->assertEquals([[4, 5, 6], [], [3], [1, 2]], $listOps->reverse([[1, 2], [3], [], [4, 5, 6]]));

0 commit comments

Comments
 (0)