protected final function assertRecompilesCorrectly(callable $function, array $argumentSets = null, O\Expression $returnExpression = null, $verifySerialization = true)
{
$interpreter = $this->verifyImplementation();
$reflection = $interpreter->getReflection($function);
$structure = $interpreter->getStructure($reflection);
$recompiledFunction = $this->recompile($reflection, $structure, $closureExpression);
if (empty($argumentSets)) {
$argumentSets = [[]];
}
foreach ($argumentSets as $argumentSet) {
$expectedReturn = call_user_func_array($function, $argumentSet);
$actualReturn = call_user_func_array($recompiledFunction, $argumentSet);
$this->assertEquals($expectedReturn, $actualReturn, 'Should return equivalent results for arguments: ' . implode(', ', array_map(function ($i) {
return var_export($i, true);
}, $argumentSet)) . '|code: ' . $closureExpression->compileDebug());
}
if ($returnExpression !== null) {
$this->assertScopedVariables($function, $returnExpression);
}
if ($verifySerialization) {
$this->assertSerializesAndUnserializedCorrectly($structure);
}
}