Skip to content

Commit 41359ef

Browse files
committed
cs
1 parent b56e178 commit 41359ef

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

tests/Utils/Arrays.map().phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use Tester\Assert;
1313
require __DIR__ . '/../bootstrap.php';
1414

1515

16-
test('', function () {
16+
test('empty array', function () {
1717
$arr = [];
1818
$log = [];
1919
$res = Arrays::map(
@@ -27,7 +27,7 @@ test('', function () {
2727
Assert::same([], $log);
2828
});
2929

30-
test('', function () {
30+
test('list', function () {
3131
$arr = ['a', 'b'];
3232
$log = [];
3333
$res = Arrays::map(
@@ -41,7 +41,7 @@ test('', function () {
4141
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
4242
});
4343

44-
test('', function () {
44+
test('array with keys', function () {
4545
$arr = ['x' => 'a', 'y' => 'b'];
4646
$log = [];
4747
$res = Arrays::map(
@@ -55,7 +55,7 @@ test('', function () {
5555
Assert::same([['a', 'x', $arr], ['b', 'y', $arr]], $log);
5656
});
5757

58-
test('', function () {
58+
test('iterator', function () {
5959
$arr = new ArrayIterator(['x' => 'a', 'y' => 'b']);
6060
$log = [];
6161
$res = Arrays::map(

tests/Utils/Finder.filters.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ test('custom filter', function () {
7676
});
7777

7878

79-
test('custom filter', function () {
80-
function filter(FileInfo $file)
81-
{
82-
return $file->getBaseName() === 'file.txt';
83-
}
79+
function filter(FileInfo $file)
80+
{
81+
return $file->getBaseName() === 'file.txt';
82+
}
8483

8584

85+
test('custom filter', function () {
8686
$finder = Finder::findFiles('*')
8787
->from('fixtures.finder')
8888
->filter('filter');

tests/Utils/Iterables.map().phpt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use Tester\Assert;
1212
require __DIR__ . '/../bootstrap.php';
1313

1414

15-
test('', function () {
15+
test('empty iterable', function () {
1616
$arr = new ArrayIterator([]);
1717
$log = [];
1818
$res = Iterables::map(
@@ -26,21 +26,7 @@ test('', function () {
2626
Assert::same([], $log);
2727
});
2828

29-
test('', function () {
30-
$arr = new ArrayIterator(['a', 'b']);
31-
$log = [];
32-
$res = Iterables::map(
33-
$arr,
34-
function ($v, $k, $arr) use (&$log) {
35-
$log[] = func_get_args();
36-
return $v . $v;
37-
},
38-
);
39-
Assert::same(['aa', 'bb'], iterator_to_array($res));
40-
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
41-
});
42-
43-
test('', function () {
29+
test('non-empty iterable', function () {
4430
$arr = new ArrayIterator(['x' => 'a', 'y' => 'b']);
4531
$log = [];
4632
$res = Iterables::map(

tests/Utils/Strings.match().phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ declare(strict_types=1);
99
use Nette\Utils\Strings;
1010
use Tester\Assert;
1111

12-
1312
require __DIR__ . '/../bootstrap.php';
1413

1514

15+
// not matched
1616
Assert::null(Strings::match('hello world!', '#([E-L])+#'));
1717

18+
19+
// capturing
1820
Assert::same(['hell', 'l'], Strings::match('hello world!', '#([e-l])+#'));
1921

2022
Assert::same(['hell'], Strings::match('hello world!', '#[e-l]+#'));
2123

24+
25+
// options
2226
Assert::same([[' ', 12]], Strings::match('россия - враг', '#\s+#u', PREG_OFFSET_CAPTURE));
2327
Assert::same([[' ', 12]], Strings::match('россия - враг', '#\s+#u', captureOffset: true));
2428

@@ -35,5 +39,7 @@ Assert::same(['žluťoučký'], Strings::match('žluťoučký kůň', '#\w+#', u
3539

3640
Assert::same([['k', 7]], Strings::match('žluťoučký kůň', '#[e-l]+#u', captureOffset: true, utf8: true, offset: 2));
3741

42+
43+
// right edge
3844
Assert::null(Strings::match('hello world!', '', offset: 50));
3945
Assert::null(Strings::match('', '', offset: 1));

tests/Utils/Strings.matchAll().phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ declare(strict_types=1);
99
use Nette\Utils\Strings;
1010
use Tester\Assert;
1111

12-
1312
require __DIR__ . '/../bootstrap.php';
1413

1514

15+
// not matched
1616
Assert::same([], Strings::matchAll('hello world!', '#([E-L])+#'));
1717

18+
19+
// capturing
1820
Assert::same([
1921
['hell', 'l'],
2022
['l', 'l'],
@@ -25,6 +27,8 @@ Assert::same([
2527
['l'],
2628
], Strings::matchAll('hello world!', '#[e-l]+#'));
2729

30+
31+
// options
2832
Assert::same([
2933
[['lu', 2], ['l', 2], ['u', 3]],
3034
[['ou', 6], ['o', 6], ['u', 7]],
@@ -75,4 +79,6 @@ Assert::same([['ll', 'l']], Strings::matchAll('hello world!', '#[e-l]+#', offset
7579

7680
Assert::same([['e', null]], Strings::matchAll('hello world!', '#e(x)*#', unmatchedAsNull: true));
7781

82+
83+
// right edge
7884
Assert::same([], Strings::matchAll('hello world!', '', offset: 50));

tests/Utils/Type.fromReflection.function.82.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ Assert::same('int', (string) $type);
5454

5555

5656
// disjunctive normal form
57-
$type = Type::fromReflection(new ReflectionFunction(function (): (Bar & Foo)|string|int|null {}));
57+
$type = Type::fromReflection(new ReflectionFunction(function (): (Bar & Foo) | string | int | null {}));
5858
Assert::same('(Bar&Foo)|string|int|null', (string) $type);

0 commit comments

Comments
 (0)