Skip to content

Commit 4f71868

Browse files
Sync isogram tests (#540)
1 parent bd200d8 commit 4f71868

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
return {
2+
module_name = 'is_isogram',
3+
4+
generate_test = function(case)
5+
local template = [[
6+
assert.is_%s(is_isogram('%s'))]]
7+
return template:format(case.expected, case.input.phrase)
8+
end
9+
}

exercises/practice/isogram/.meta/tests.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[a0e97d2d-669e-47c7-8134-518a1e2c4555]
613
description = "empty string"
@@ -40,3 +47,6 @@ description = "duplicated character in the middle"
4047

4148
[310ac53d-8932-47bc-bbb4-b2b94f25a83e]
4249
description = "same first and last characters"
50+
51+
[0d0b8644-0a1e-4a31-a432-2b3ee270d847]
52+
description = "word with duplicated character and with two hyphens"
Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,59 @@
1-
local is_isogram = require 'isogram'
1+
local is_isogram = require('isogram')
22

33
describe('isogram', function()
4-
it('should identify simple isograms', function()
5-
assert.is_true(is_isogram('duplicates'))
6-
assert.is_true(is_isogram('subdermatoglyphic'))
4+
it('empty string', function()
5+
assert.is_true(is_isogram(''))
6+
end)
7+
8+
it('isogram with only lower case characters', function()
9+
assert.is_true(is_isogram('isogram'))
710
end)
811

9-
it('should identify words with repeated letters as non-isograms', function()
12+
it('word with one duplicated character', function()
1013
assert.is_false(is_isogram('eleven'))
1114
end)
1215

13-
it('should be case insensitive', function()
16+
it('word with one duplicated character from the end of the alphabet', function()
17+
assert.is_false(is_isogram('zzyzx'))
18+
end)
19+
20+
it('longest reported english isogram', function()
21+
assert.is_true(is_isogram('subdermatoglyphic'))
22+
end)
23+
24+
it('word with duplicated character in mixed case', function()
1425
assert.is_false(is_isogram('Alphabet'))
1526
end)
1627

17-
it('should allow punctuations in isograms', function()
28+
it('word with duplicated character in mixed case, lowercase first', function()
29+
assert.is_false(is_isogram('alphAbet'))
30+
end)
31+
32+
it('hypothetical isogrammic word with hyphen', function()
1833
assert.is_true(is_isogram('thumbscrew-japingly'))
1934
end)
2035

21-
it('should allow repeated punctuation in isograms', function()
22-
assert.is_true(is_isogram('Hjelmqvist-Gryb-Zock-Pfund-Wax'))
36+
it('hypothetical word with duplicated character following hyphen', function()
37+
assert.is_false(is_isogram('thumbscrew-jappingly'))
2338
end)
2439

25-
it('should identify non-isogram sentences', function()
26-
assert.is_false(is_isogram('the quick brown fox'))
40+
it('isogram with duplicated hyphen', function()
41+
assert.is_true(is_isogram('six-year-old'))
2742
end)
2843

29-
it('should identify isogram sentences', function()
44+
it('made-up name that is an isogram', function()
3045
assert.is_true(is_isogram('Emily Jung Schwartzkopf'))
3146
end)
47+
48+
it('duplicated character in the middle', function()
49+
assert.is_false(is_isogram('accentor'))
50+
end)
51+
52+
it('same first and last characters', function()
53+
assert.is_false(is_isogram('angola'))
54+
end)
55+
56+
it('word with duplicated character and with two hyphens', function()
57+
assert.is_false(is_isogram('up-to-date'))
58+
end)
3259
end)

0 commit comments

Comments
 (0)