Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6098877
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
Oct 6 2026, 06:36 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
dc/fa/80c10c0ff9631cbd3e2f481b16d6
Default Alt Text
ElementsTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment