Skip to content

Commit

Permalink
patch: remove order dependency from anagram test (#873)
Browse files Browse the repository at this point in the history
[no important files changed]
  • Loading branch information
neenjaw authored Jan 25, 2025
1 parent aa40d0b commit 70eb1d7
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions exercises/practice/anagram/AnagramTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function setUpBeforeClass(): void
*/
public function testNoMatches(): void
{
$this->assertEquals([], detectAnagrams('diaper', ['hello', 'world', 'zombies', 'pants']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('diaper', ['hello', 'world', 'zombies', 'pants'])));
}

/**
Expand All @@ -24,9 +24,9 @@ public function testNoMatches(): void
*/
public function testDetectsTwoAnagrams(): void
{
$this->assertEquals(
$this->assertEqualsCanonicalizing(
['lemons', 'melons'],
detectAnagrams('solemn', ['lemons', 'cherry', 'melons'])
array_values(detectAnagrams('solemn', ['lemons', 'cherry', 'melons']))
);
}

Expand All @@ -36,7 +36,7 @@ public function testDetectsTwoAnagrams(): void
*/
public function testDoesNotDetectAnagramSubsets(): void
{
$this->assertEquals([], detectAnagrams('good', ['dog', 'goody']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('good', ['dog', 'goody'])));
}

/**
Expand All @@ -45,7 +45,7 @@ public function testDoesNotDetectAnagramSubsets(): void
*/
public function testDetectsAnagram(): void
{
$this->assertEquals(['inlets'], detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana']));
$this->assertEqualsCanonicalizing(['inlets'], array_values(detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana'])));
}

/**
Expand All @@ -54,9 +54,9 @@ public function testDetectsAnagram(): void
*/
public function testDetectsThreeAnagrams(): void
{
$this->assertEquals(
$this->assertEqualsCanonicalizing(
['gallery', 'regally', 'largely'],
detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading'])
array_values(detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']))
);
}

Expand All @@ -66,7 +66,7 @@ public function testDetectsThreeAnagrams(): void
*/
public function testDetectsMultipleAnagramsWithDifferentCase(): void
{
$this->assertEquals(['Eons', 'ONES'], detectAnagrams('nose', ['Eons', 'ONES']));
$this->assertEqualsCanonicalizing(['Eons', 'ONES'], array_values(detectAnagrams('nose', ['Eons', 'ONES'])));
}

/**
Expand All @@ -75,7 +75,7 @@ public function testDetectsMultipleAnagramsWithDifferentCase(): void
*/
public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void
{
$this->assertEquals([], detectAnagrams('mass', ['last']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('mass', ['last'])));
}

/**
Expand All @@ -84,7 +84,7 @@ public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void
*/
public function testDetectsAnagramsCaseInsensitively(): void
{
$this->assertEquals(['Carthorse'], detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes']));
$this->assertEqualsCanonicalizing(['Carthorse'], array_values(detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes'])));
}

/**
Expand All @@ -93,7 +93,7 @@ public function testDetectsAnagramsCaseInsensitively(): void
*/
public function testDetectsAnagramsUsingCaseInsensitiveSubject(): void
{
$this->assertEquals(['carthorse'], detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes']));
$this->assertEqualsCanonicalizing(['carthorse'], array_values(detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes'])));
}

/**
Expand All @@ -102,7 +102,7 @@ public function testDetectsAnagramsUsingCaseInsensitiveSubject(): void
*/
public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void
{
$this->assertEquals(['Carthorse'], detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes']));
$this->assertEqualsCanonicalizing(['Carthorse'], array_values(detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes'])));
}

/**
Expand All @@ -111,7 +111,7 @@ public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void
*/
public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void
{
$this->assertEquals([], detectAnagrams('go', ['goGoGO']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('go', ['goGoGO'])));
}

/**
Expand All @@ -120,7 +120,7 @@ public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void
*/
public function testAnagramsMustUseAllLettersExactlyOnce(): void
{
$this->assertEquals([], detectAnagrams('tapper', ['patter']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('tapper', ['patter'])));
}

/**
Expand All @@ -129,7 +129,7 @@ public function testAnagramsMustUseAllLettersExactlyOnce(): void
*/
public function testWordsAreNotAnagramsOfThemselves(): void
{
$this->assertEquals([], detectAnagrams('BANANA', ['BANANA']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['BANANA'])));
}

/**
Expand All @@ -138,7 +138,7 @@ public function testWordsAreNotAnagramsOfThemselves(): void
*/
public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDifferent(): void
{
$this->assertEquals([], detectAnagrams('BANANA', ['Banana']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['Banana'])));
}

/**
Expand All @@ -147,7 +147,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDi
*/
public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDifferent(): void
{
$this->assertEquals([], detectAnagrams('BANANA', ['banana']));
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['banana'])));
}

/**
Expand All @@ -156,7 +156,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyD
*/
public function testWordsOtherThanThemselvesCanBeAnagrams(): void
{
$this->assertEquals(['Silent'], detectAnagrams('LISTEN', ['LISTEN', 'Silent']));
$this->assertEqualsCanonicalizing(['Silent'], array_values(detectAnagrams('LISTEN', ['LISTEN', 'Silent'])));
}

/**
Expand Down

0 comments on commit 70eb1d7

Please sign in to comment.