Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1430696
ElementsTest.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
ElementsTest.php
View Options
<?php
use
Eris\Generators
;
class
ElementsTest
extends
\PHPUnit\Framework\TestCase
{
use
Eris\TestTrait
;
public
function
testElementsOnlyProducesElementsFromTheGivenArguments
()
{
$this
->
forAll
(
Generators
::
elements
(
1
,
2
,
3
)
)
->
then
(
function
(
$number
)
{
$this
->
assertContains
(
$number
,
[
1
,
2
,
3
]
);
});
}
/**
* This means you cannot have a Elements Generator with a single element,
* which is perfectly fine as if you have a single element this generator
* is useless. Use Constant Generator instead
*/
public
function
testElementsOnlyProducesElementsFromTheGivenArrayDomain
()
{
$this
->
forAll
(
Generators
::
elements
([
1
,
2
,
3
])
)
->
then
(
function
(
$number
)
{
$this
->
assertContains
(
$number
,
[
1
,
2
,
3
]
);
});
}
public
function
testVectorOfElementsGenerators
()
{
$this
->
forAll
(
Generators
::
vector
(
4
,
Generators
::
elements
([
2
,
4
,
6
,
8
,
10
,
12
])
)
)
->
then
(
function
(
$vector
)
{
$sum
=
array_sum
(
$vector
);
$isEven
=
function
(
$number
)
{
return
$number
%
2
==
0
;
};
$this
->
assertTrue
(
$isEven
(
$sum
),
"$sum is not even, but it's the sum of the vector "
.
var_export
(
$vector
,
true
)
);
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 19:25 (5 h, 28 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
dc/57/1049a4d371390cce021892c44c55
Default Alt Text
ElementsTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment