Skip to content

Commit 90f2cc6

Browse files
kishansmalley
kishan
authored andcommitted
pig-latin: update tests to version 1.1.0 (exercism#1034)
* pig-latin: Updates tests * pig-latin: Fix example to work with new tests
1 parent 9d89efc commit 90f2cc6

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

exercises/pig-latin/example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22

3-
re_cons = re.compile('^([^aeiou]?qu|[^aeiou]+)([a-z]*)')
3+
4+
re_cons = re.compile('^([^aeiou]?qu|[^aeiouy]+|y(?=[aeiou]))([a-z]*)')
45
re_vowel = re.compile('^([aeiou]|y[^aeiou]|xr)[a-z]*')
56

67

exercises/pig-latin/pig_latin_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pig_latin import translate
44

55

6-
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
6+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
77

88
class PigLatinTests(unittest.TestCase):
99
def test_word_beginning_with_a(self):
@@ -30,9 +30,6 @@ def test_word_beginning_with_p(self):
3030
def test_word_beginning_with_k(self):
3131
self.assertEqual(translate("koala"), "oalakay")
3232

33-
def test_word_beginning_with_y(self):
34-
self.assertEqual(translate("yellow"), "ellowyay")
35-
3633
def test_word_beginning_with_x(self):
3734
self.assertEqual(translate("xenon"), "enonxay")
3835

@@ -63,6 +60,15 @@ def test_word_beginning_with_yt(self):
6360
def test_word_beginning_with_xr(self):
6461
self.assertEqual(translate("xray"), "xrayay")
6562

63+
def test_y_is_treated_like_a_consonant_at_the_beginning_of_a_word(self):
64+
self.assertEqual(translate("yellow"), "ellowyay")
65+
66+
def test_y_is_treated_like_a_vowel_at_the_end_of_a_consonant_cluster(self):
67+
self.assertEqual(translate("rhythm"), "ythmrhay")
68+
69+
def test_y_as_second_letter_in_two_letter_word(self):
70+
self.assertEqual(translate("my"), "ymay")
71+
6672
def test_a_whole_phrase(self):
6773
self.assertEqual(translate("quick fast run"), "ickquay astfay unray")
6874

0 commit comments

Comments
 (0)