FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
fp4php/tests/FunctionsTest.php at master · fp4php/fp4php · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
fp4php
/
fp4php
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
8
Code
Issues
10
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
fp4php
/
tests
/
FunctionsTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
120 lines (107 loc) · 2.99 KB
Breadcrumbs
fp4php
/
tests
/
FunctionsTest.php
Copy path
File metadata and controls
120 lines (107 loc) · 2.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
declare
(strict_types=
1
);
namespace
Fp4
\
PHP
\
Test
;
use
DateTimeImmutable
;
use
Fp4
\
PHP
\
ArrayList
as
L
;
use
Fp4
\
PHP
\
PHPUnit
as
Assert
;
use
Fp4
\
PHP
\
PsalmIntegration
as
Type
;
use
Fp4
\
PHP
\
Shape
as
S
;
use
Fp4
\
PHP
\
Test
\
Fixture
\
InheritedObj
;
use
PHPUnit
\
Framework
\
Attributes
\
Test
;
use
PHPUnit
\
Framework
\
TestCase
;
use
function
Fp4
\
PHP
\
Combinator
\
constFalse
;
use
function
Fp4
\
PHP
\
Combinator
\
constNull
;
use
function
Fp4
\
PHP
\
Combinator
\
constTrue
;
use
function
Fp4
\
PHP
\
Combinator
\
constVoid
;
use
function
Fp4
\
PHP
\
Combinator
\
ctor
;
use
function
Fp4
\
PHP
\
Combinator
\
id
;
use
function
Fp4
\
PHP
\
Combinator
\
pipe
;
use
function
Fp4
\
PHP
\
Combinator
\
tupled
;
use
function
PHPUnit
\
Framework
\
assertEquals
;
use
function
PHPUnit
\
Framework
\
assertFalse
;
use
function
PHPUnit
\
Framework
\
assertNull
;
use
function
PHPUnit
\
Framework
\
assertTrue
;
/**
* @api
*/
final
class
FunctionsTest
extends
TestCase
{
#[Test]
public
static
function
pipe
():
void
{
assertEquals
(
42
,
pipe
(
40
,
fn
(
int
$
i
) =>
$
i
-
1
,
fn
(
int
$
i
) =>
$
i
+
3
,
));
}
#[Test]
public
static
function
constNull
():
void
{
assertNull
(
constNull
());
}
#[Test]
public
static
function
constVoid
():
void
{
assertNull
(
constVoid
());
}
#[Test]
public
static
function
id
():
void
{
assertEquals
(
42
,
id
(
42
));
}
#[Test]
public
static
function
constTrue
():
void
{
assertTrue
(
constTrue
());
}
#[Test]
public
static
function
constFalse
():
void
{
assertFalse
(
constFalse
());
}
#[Test]
public
static
function
ctor
():
void
{
pipe
(
ctor
(DateTimeImmutable::class),
Type
\isSameAs
(
'
Closure(string=, \DateTimeZone|null=): \DateTimeImmutable
'
),
fn
(
$
createDateTime
) =>
$
createDateTime
(
'
2023-06-07
'
),
Assert
\equals
(
new
DateTimeImmutable
(
'
2023-06-07
'
)),
);
}
#[Test]
public
static
function
tupled
():
void
{
pipe
(
L
\from
([
S
\from
([
'
test1
'
,
40
]),
S
\from
([
'
test2
'
,
41
]),
S
\from
([
'
test3
'
,
42
]),
]),
L
\map
(
tupled
(
fn
(
$
a
,
$
b
) =>
new
InheritedObj
(
$
a
,
$
b
))),
Type
\isSameAs
(
'
list<InheritedObj>
'
),
Assert
\equals
([
new
InheritedObj
(prop1:
'
test1
'
, prop2:
40
),
new
InheritedObj
(prop1:
'
test2
'
, prop2:
41
),
new
InheritedObj
(prop1:
'
test3
'
, prop2:
42
),
]),
);
pipe
(
L
\from
([
S
\from
([
'
test1
'
,
40
]),
S
\from
([
'
test2
'
,
41
]),
S
\from
([
'
test3
'
,
42
]),
]),
L
\map
(
tupled
(
ctor
(InheritedObj::class)),
),
Type
\isSameAs
(
'
list<InheritedObj>
'
),
Assert
\equals
([
new
InheritedObj
(prop1:
'
test1
'
, prop2:
40
),
new
InheritedObj
(prop1:
'
test2
'
, prop2:
41
),
new
InheritedObj
(prop1:
'
test3
'
, prop2:
42
),
]),
);
}
}
Back
|
FazBrowse Home
|
New Git URL