Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: remove order dependency from anagram test #873

Merged
merged 18 commits into from
Jan 25, 2025
Merged
Changes from 3 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
32 changes: 16 additions & 16 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,7 +24,7 @@ public function testNoMatches(): void
*/
public function testDetectsTwoAnagrams(): void
{
$this->assertEquals(
$this->assertEqualsCanonicalizing(
['lemons', 'melons'],
detectAnagrams('solemn', ['lemons', 'cherry', 'melons'])
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
);
Expand All @@ -36,7 +36,7 @@ public function testDetectsTwoAnagrams(): void
*/
public function testDoesNotDetectAnagramSubsets(): void
{
$this->assertEquals([], detectAnagrams('good', ['dog', 'goody']));
$this->assertEqualsCanonicalizing([], detectAnagrams('good', ['dog', 'goody']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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'], detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -54,7 +54,7 @@ public function testDetectsAnagram(): void
*/
public function testDetectsThreeAnagrams(): void
{
$this->assertEquals(
$this->assertEqualsCanonicalizing(
['gallery', 'regally', 'largely'],
detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading'])
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
);
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'], detectAnagrams('nose', ['Eons', 'ONES']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -75,7 +75,7 @@ public function testDetectsMultipleAnagramsWithDifferentCase(): void
*/
public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void
{
$this->assertEquals([], detectAnagrams('mass', ['last']));
$this->assertEqualsCanonicalizing([], detectAnagrams('mass', ['last']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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'], detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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'], detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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'], detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -111,7 +111,7 @@ public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void
*/
public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void
{
$this->assertEquals([], detectAnagrams('go', ['goGoGO']));
$this->assertEqualsCanonicalizing([], detectAnagrams('go', ['goGoGO']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -120,7 +120,7 @@ public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void
*/
public function testAnagramsMustUseAllLettersExactlyOnce(): void
{
$this->assertEquals([], detectAnagrams('tapper', ['patter']));
$this->assertEqualsCanonicalizing([], detectAnagrams('tapper', ['patter']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -129,7 +129,7 @@ public function testAnagramsMustUseAllLettersExactlyOnce(): void
*/
public function testWordsAreNotAnagramsOfThemselves(): void
{
$this->assertEquals([], detectAnagrams('BANANA', ['BANANA']));
$this->assertEqualsCanonicalizing([], detectAnagrams('BANANA', ['BANANA']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -138,7 +138,7 @@ public function testWordsAreNotAnagramsOfThemselves(): void
*/
public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDifferent(): void
{
$this->assertEquals([], detectAnagrams('BANANA', ['Banana']));
$this->assertEqualsCanonicalizing([], detectAnagrams('BANANA', ['Banana']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -147,7 +147,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDi
*/
public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDifferent(): void
{
$this->assertEquals([], detectAnagrams('BANANA', ['banana']));
$this->assertEqualsCanonicalizing([], detectAnagrams('BANANA', ['banana']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -156,7 +156,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyD
*/
public function testWordsOtherThanThemselvesCanBeAnagrams(): void
{
$this->assertEquals(['Silent'], detectAnagrams('LISTEN', ['LISTEN', 'Silent']));
$this->assertEqualsCanonicalizing(['Silent'], detectAnagrams('LISTEN', ['LISTEN', 'Silent']));
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down