Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Use print_r instead of var_export for failed object identity comp…
Browse files Browse the repository at this point in the history
…arissons

`var_export()` hits a stack limit on large objects, e.g. HHAST trees
  • Loading branch information
fredemmott committed Nov 13, 2020
1 parent 01ec773 commit c285118
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Assert.hack
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,16 @@ abstract class Assert {
if (!$actual is string) {
$actual = \var_export($actual, true);
}
throw new ExpectationFailedException(
Str\format(
"%s\nFailed asserting that two values are the same:\n%s\n",
$message,
StringDiff::lines($expected, $actual)->getUnifiedDiff(),
),
);
} else {
$expected = \print_r($expected, true);
$actual = \print_r($actual, true);
}

throw new ExpectationFailedException(
Str\format(
"%s\nFailed asserting that %s is the same as %s",
"%s\nFailed asserting that two values are the same:\n%s\n",
$message,
\var_export($actual, true),
\var_export($expected, true),
StringDiff::lines($expected, $actual)->getUnifiedDiff(),
),
);
}
Expand Down

0 comments on commit c285118

Please sign in to comment.