Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Differ.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ private function finalize(): self

$this->oldNoEolAtEofIdx = $this->getOld(-1) === [''] ? -1 : \count($this->old);
$this->newNoEolAtEofIdx = $this->getNew(-1) === [''] ? -1 : \count($this->new);
$this->oldNewComparison = $this->old <=> $this->new;
$this->oldNewComparison = $this->old === $this->new ? 0 : ($this->old <=> $this->new ?: 1);

$this->sequenceMatcher->setOptions($this->options->toSequenceMatcherOptions());
}
Expand Down
13 changes: 13 additions & 0 deletions tests/DifferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
*/
final class DifferTest extends TestCase
{
/**
* Test that numeric strings that are equal numerically but not identical
* (e.g. "00" vs "0") are correctly detected as different.
*
* @covers \Jfcherng\Diff\Differ::getOldNewComparison
*/
public function testNumericStringComparisonIsStrict(): void
{
$differ = new Differ(['00'], ['0']);

self::assertNotSame(0, $differ->getOldNewComparison());
}

/**
* Test the Differ::getGroupedOpcodes.
*
Expand Down
Loading