Page MenuHomeWickedGov Phorge

SumTest.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

SumTest.php

<?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

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)

Event Timeline