Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7468493
MapGeneratorTest.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
MapGeneratorTest.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Random\RandomRange
;
use
Eris\Random\RandSource
;
class
MapGeneratorTest
extends
\PHPUnit\Framework\TestCase
{
/**
* @var int
*/
private
$size
;
/**
* @var RandomRange
*/
private
$rand
;
protected
function
setUp
():
void
{
$this
->
size
=
10
;
$this
->
rand
=
new
RandomRange
(
new
RandSource
());
}
public
function
testGeneratesAGeneratedValueObject
()
{
$generator
=
new
MapGenerator
(
function
(
$n
)
{
return
$n
*
2
;
},
ConstantGenerator
::
box
(
1
)
);
$this
->
assertEquals
(
2
,
$generator
->
__invoke
(
$this
->
size
,
$this
->
rand
)->
unbox
()
);
}
public
function
testShrinksTheOriginalInput
()
{
$generator
=
new
MapGenerator
(
function
(
$n
)
{
return
$n
*
2
;
},
new
ChooseGenerator
(
1
,
100
)
);
$element
=
$generator
->
__invoke
(
$this
->
size
,
$this
->
rand
);
$elementAfterShrink
=
$generator
->
shrink
(
$element
);
$this
->
assertTrue
(
$elementAfterShrink
->
unbox
()
<=
$element
->
unbox
(),
"Element should have diminished in size"
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 23, 06:35 (3 d, 14 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
37/a8/cb17c07411fb12eb445cd8ddf209
Default Alt Text
MapGeneratorTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment