Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6167794
MapTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
MapTest.php
View Options
<?php
use
Eris\Generators
;
class
MapTest
extends
\PHPUnit\Framework\TestCase
{
use
Eris\TestTrait
;
public
function
testApplyingAFunctionToGeneratedValues
()
{
$this
->
forAll
(
Generators
::
vector
(
3
,
Generators
::
map
(
function
(
$n
)
{
return
$n
*
2
;
},
Generators
::
nat
()
)
)
)
->
then
(
function
(
$tripleOfEvenNumbers
)
{
foreach
(
$tripleOfEvenNumbers
as
$number
)
{
$this
->
assertTrue
(
$number
%
2
==
0
,
"The element of the vector $number is not even"
);
}
});
}
public
function
testShrinkingJustMappedValues
()
{
$this
->
forAll
(
Generators
::
map
(
function
(
$n
)
{
return
$n
*
2
;
},
Generators
::
nat
()
)
)
->
then
(
function
(
$evenNumber
)
{
$this
->
assertLessThanOrEqual
(
100
,
$evenNumber
,
"The number is not less than 100"
);
});
}
public
function
testShrinkingMappedValuesInsideOtherGenerators
()
{
$this
->
forAll
(
Generators
::
vector
(
3
,
Generators
::
map
(
function
(
$n
)
{
return
$n
*
2
;
},
Generators
::
nat
()
)
)
)
->
then
(
function
(
$tripleOfEvenNumbers
)
{
$this
->
assertLessThanOrEqual
(
100
,
array_sum
(
$tripleOfEvenNumbers
),
"The triple sum "
.
var_export
(
$tripleOfEvenNumbers
,
true
)
.
" is not less than 100"
);
});
}
// TODO: multiple generators means multiple values passed to map
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 8 2026, 17:46 (7 w, 9 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
78/b4/41d159e2073101237579146e0048
Default Alt Text
MapTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment