Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5973855
SumTest.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
SumTest.php
View Options
<?php
use
Eris\Generators
;
function
my_sum
(
$first
,
$second
)
{
if
(
$first
>=
42
)
{
return
$first
+
$second
+
1
;
}
return
$first
+
$second
;
}
class
SumTest
extends
\PHPUnit\Framework\TestCase
{
use
Eris\TestTrait
;
public
function
testRightIdentityElement
()
{
$this
->
forAll
(
Generators
::
nat
()
)
->
then
(
function
(
$number
)
{
$this
->
assertEquals
(
$number
,
my_sum
(
$number
,
0
),
"Summing $number to 0"
);
});
}
public
function
testLeftIdentityElement
()
{
$this
->
forAll
(
Generators
::
nat
()
)
->
then
(
function
(
$number
)
{
$this
->
assertEquals
(
$number
,
my_sum
(
0
,
$number
),
"Summing 0 to $number"
);
});
}
public
function
testEqualToReferencePhpImplementation
()
{
$this
->
forAll
(
Generators
::
nat
(),
Generators
::
nat
()
)
->
then
(
function
(
$first
,
$second
)
{
$this
->
assertEquals
(
$first
+
$second
,
my_sum
(
$first
,
$second
),
"Summing $first and $second"
);
});
}
public
function
testPropertyNeverSatisfied
()
{
$this
->
forAll
(
Generators
::
nat
(),
Generators
::
nat
()
)
->
then
(
function
(
$first
,
$second
)
{
$this
->
assertEquals
(
-
1
,
my_sum
(
$first
,
$second
),
"Summing $first and $second"
);
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 16:54 (21 h, 34 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
28/d2/8c585b3f13a3b061419232004360
Default Alt Text
SumTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment