Skip to content

Commit 3f3cdde

Browse files
authored
Update tests anagram (#2661)
* Syncing test.toml and updating tests * Running prettier
1 parent ec2cc20 commit 3f3cdde

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

exercises/practice/anagram/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"draalger",
99
"gabriel376",
1010
"gargrave",
11+
"jagdish-15",
1112
"kytrinyx",
1213
"matthewmorgan",
1314
"ovidiu141",

exercises/practice/anagram/.meta/tests.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,41 @@ description = "detects anagrams using case-insensitive possible matches"
4646

4747
[7cc195ad-e3c7-44ee-9fd2-d3c344806a2c]
4848
description = "does not detect an anagram if the original word is repeated"
49+
include = false
50+
51+
[630abb71-a94e-4715-8395-179ec1df9f91]
52+
description = "does not detect an anagram if the original word is repeated"
53+
reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c"
4954

5055
[9878a1c9-d6ea-4235-ae51-3ea2befd6842]
5156
description = "anagrams must use all letters exactly once"
5257

5358
[85757361-4535-45fd-ac0e-3810d40debc1]
5459
description = "words are not anagrams of themselves (case-insensitive)"
60+
include = false
61+
62+
[68934ed0-010b-4ef9-857a-20c9012d1ebf]
63+
description = "words are not anagrams of themselves"
64+
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"
65+
66+
[589384f3-4c8a-4e7d-9edc-51c3e5f0c90e]
67+
description = "words are not anagrams of themselves even if letter case is partially different"
68+
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"
69+
70+
[ba53e423-7e02-41ee-9ae2-71f91e6d18e6]
71+
description = "words are not anagrams of themselves even if letter case is completely different"
72+
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"
5573

5674
[a0705568-628c-4b55-9798-82e4acde51ca]
5775
description = "words other than themselves can be anagrams"
76+
include = false
77+
78+
[33d3f67e-fbb9-49d3-a90e-0beb00861da7]
79+
description = "words other than themselves can be anagrams"
80+
reimplements = "a0705568-628c-4b55-9798-82e4acde51ca"
81+
82+
[a6854f66-eec1-4afd-a137-62ef2870c051]
83+
description = "handles case of greek letters"
84+
85+
[fd3509e5-e3ba-409d-ac3d-a9ac84d13296]
86+
description = "different characters may have the same bytes"

exercises/practice/anagram/anagram.spec.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('Anagram', () => {
9696

9797
xtest('does not detect an anagram if the original word is repeated', () => {
9898
const expected = [];
99-
const actual = findAnagrams('go', ['go Go GO']);
99+
const actual = findAnagrams('go', ['goGoGO']);
100100
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
101101
});
102102

@@ -106,15 +106,39 @@ describe('Anagram', () => {
106106
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
107107
});
108108

109-
xtest('words are not anagrams of themselves (case-insensitive)', () => {
109+
xtest('words are not anagrams of themselves', () => {
110110
const expected = [];
111-
const actual = findAnagrams('BANANA', ['BANANA', 'Banana', 'banana']);
111+
const actual = findAnagrams('BANANA', ['BANANA']);
112+
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
113+
});
114+
115+
xtest('words are not anagrams of themselves even if letter case is partially different', () => {
116+
const expected = [];
117+
const actual = findAnagrams('BANANA', ['Banana']);
118+
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
119+
});
120+
121+
xtest('words are not anagrams of themselves even if letter case is completely different', () => {
122+
const expected = [];
123+
const actual = findAnagrams('BANANA', ['banana']);
112124
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
113125
});
114126

115127
xtest('words other than themselves can be anagrams', () => {
116128
const expected = ['Silent'];
117-
const actual = findAnagrams('LISTEN', ['Listen', 'Silent', 'LISTEN']);
129+
const actual = findAnagrams('LISTEN', ['LISTEN', 'Silent']);
130+
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
131+
});
132+
133+
xtest('handles case of greek letters', () => {
134+
const expected = ['ΒΓΑ', 'γβα'];
135+
const actual = findAnagrams('ΑΒΓ', ['ΒΓΑ', 'ΒΓΔ', 'γβα', 'αβγ']);
136+
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
137+
});
138+
139+
xtest('different characters may have the same bytes', () => {
140+
const expected = [];
141+
const actual = findAnagrams('a⬂', ['€a']);
118142
expect(areSetsEqual(new Set(expected), new Set(actual))).toEqual(true);
119143
});
120144
});

0 commit comments

Comments
 (0)