Skip to content

pig-latin: update tests to version 1.1.0 #1034

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

Merged
merged 8 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion exercises/pig-latin/example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re

re_cons = re.compile('^([^aeiou]?qu|[^aeiou]+)([a-z]*)')

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


Expand Down
14 changes: 10 additions & 4 deletions exercises/pig-latin/pig_latin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pig_latin import translate


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

class PigLatinTests(unittest.TestCase):
def test_word_beginning_with_a(self):
Expand All @@ -30,9 +30,6 @@ def test_word_beginning_with_p(self):
def test_word_beginning_with_k(self):
self.assertEqual(translate("koala"), "oalakay")

def test_word_beginning_with_y(self):
self.assertEqual(translate("yellow"), "ellowyay")

def test_word_beginning_with_x(self):
self.assertEqual(translate("xenon"), "enonxay")

Expand Down Expand Up @@ -63,6 +60,15 @@ def test_word_beginning_with_yt(self):
def test_word_beginning_with_xr(self):
self.assertEqual(translate("xray"), "xrayay")

def test_y_is_treated_like_a_consonant_at_the_beginning_of_a_word(self):
self.assertEqual(translate("yellow"), "ellowyay")

def test_y_is_treated_like_a_vowel_at_the_end_of_a_consonant_cluster(self):
self.assertEqual(translate("rhythm"), "ythmrhay")

def test_y_as_second_letter_in_two_letter_word(self):
self.assertEqual(translate("my"), "ymay")

def test_a_whole_phrase(self):
self.assertEqual(translate("quick fast run"), "ickquay astfay unray")

Expand Down