Page MenuHomeWickedGov Phorge

ShrinkingTimeLimitTest.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ShrinkingTimeLimitTest.php

<?php
use Eris\Generator;
use Eris\Generators;
function very_slow_concatenation($first, $second)
{
if (strlen($second) > 10) {
sleep(2);
$second .= 'ERROR';
}
return $first . $second;
}
class ShrinkingTimeLimitTest extends \PHPUnit\Framework\TestCase
{
use Eris\TestTrait;
public function testLengthPreservation()
{
$this
->shrinkingTimeLimit(2)
->forAll(
Generators::string(),
Generators::string()
)
->then(function ($first, $second) {
$result = very_slow_concatenation($first, $second);
$this->assertEquals(
strlen($first) + strlen($second),
strlen($result),
"Concatenating '$first' to '$second' gives '$result'" . PHP_EOL
);
});
}
/**
* @eris-shrink 2
*/
public function testLengthPreservationFromAnnotation()
{
$this
->forAll(
Generator\string(),
Generator\string()
)
->then(function ($first, $second) {
$result = very_slow_concatenation($first, $second);
$this->assertEquals(
strlen($first) + strlen($second),
strlen($result),
"Concatenating '$first' to '$second' gives '$result'" . PHP_EOL
);
});
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Nov 23, 19:04 (6 d, 5 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ba/e9/145dc5e08060c6cbd452c6ed84a3
Default Alt Text
ShrinkingTimeLimitTest.php (1 KB)

Event Timeline