Skip to content

Commit

Permalink
Merge pull request #420 from DonCallisto/memory_optimization
Browse files Browse the repository at this point in the history
Introduced and fixed CachedDoubler behaviour in order to reduce memor…
  • Loading branch information
ciaranmcnulty authored Dec 17, 2019
2 parents 278880e + 28f7b6a commit 6315aad
Show file tree
Hide file tree
Showing 10 changed files with 456 additions and 35 deletions.
5 changes: 4 additions & 1 deletion spec/Prophecy/Argument/ArgumentsWildcardSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ function it_wraps_non_token_arguments_into_ExactValueToken(\stdClass $object)
$class = get_class($object->getWrappedObject());
$hash = spl_object_hash($object->getWrappedObject());

$this->__toString()->shouldReturn("exact(42), exact(\"zet\"), exact($class:$hash Object (\n 'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)\n))");
$objHash = "exact(42), exact(\"zet\"), exact($class:$hash Object (\n 'objectProphecyClosure' => Closure:%s Object (\n 0 => Closure:%s Object\n )\n))";

$hashRegexExpr = '[a-f0-9]{32}';
$this->__toString()->shouldMatch(sprintf('/^%s$/', sprintf(preg_quote("$objHash"), $hashRegexExpr, $hashRegexExpr)));
}

function it_generates_string_representation_from_all_tokens_imploded(
Expand Down
8 changes: 5 additions & 3 deletions spec/Prophecy/Argument/Token/ExactValueTokenSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ function it_generates_proper_string_representation_for_resource()

function it_generates_proper_string_representation_for_object(\stdClass $object)
{
$objHash = sprintf('%s:%s',
$objHash = sprintf('exact(%s:%s',
get_class($object->getWrappedObject()),
spl_object_hash($object->getWrappedObject())
);
) . " Object (\n 'objectProphecyClosure' => Closure:%s Object (\n 0 => Closure:%s Object\n )\n))";

$this->beConstructedWith($object);
$this->__toString()->shouldReturn("exact($objHash Object (\n 'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)\n))");

$hashRegexExpr = '[a-f0-9]{32}';
$this->__toString()->shouldMatch(sprintf('/^%s$/', sprintf(preg_quote("$objHash"), $hashRegexExpr, $hashRegexExpr)));
}
}

Expand Down
8 changes: 5 additions & 3 deletions spec/Prophecy/Argument/Token/IdenticalValueTokenSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ function it_generates_proper_string_representation_for_resource()

function it_generates_proper_string_representation_for_object($object)
{
$objHash = sprintf('%s:%s',
$objHash = sprintf('identical(%s:%s',
get_class($object->getWrappedObject()),
spl_object_hash($object->getWrappedObject())
);
) . " Object (\n 'objectProphecyClosure' => Closure:%s Object (\n 0 => Closure:%s Object\n )\n))";

$this->beConstructedWith($object);
$this->__toString()->shouldReturn("identical($objHash Object (\n 'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)\n))");

$hashRegexExpr = '[a-f0-9]{32}';
$this->__toString()->shouldMatch(sprintf('/^%s$/', sprintf(preg_quote("$objHash"), $hashRegexExpr, $hashRegexExpr)));
}
}
Loading

0 comments on commit 6315aad

Please sign in to comment.