From 7213e39a7c224f688665d9923836b32519da1eac Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 25 Oct 2017 18:18:17 +0530 Subject: [PATCH 1/3] Updates tests --- exercises/pig-latin/pig_latin_test.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/exercises/pig-latin/pig_latin_test.py b/exercises/pig-latin/pig_latin_test.py index 9fb5be9f82..a36d4e11ec 100644 --- a/exercises/pig-latin/pig_latin_test.py +++ b/exercises/pig-latin/pig_latin_test.py @@ -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): @@ -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") @@ -62,7 +59,16 @@ 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_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") From e923dc4c9a9dde730eb55ec7f641cc974103fe9a Mon Sep 17 00:00:00 2001 From: kishan Date: Thu, 26 Oct 2017 10:24:17 +0530 Subject: [PATCH 2/3] Trying to fix flake8 errors --- exercises/pig-latin/pig_latin_test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/pig-latin/pig_latin_test.py b/exercises/pig-latin/pig_latin_test.py index a36d4e11ec..57f6436624 100644 --- a/exercises/pig-latin/pig_latin_test.py +++ b/exercises/pig-latin/pig_latin_test.py @@ -59,16 +59,16 @@ 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_test_y_is_treated_like_a_vowel_at_the_end_of_a_consonant_cluster(self): + + 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") From ee8915d869398f4f483b0d7ae21166690b04e8f6 Mon Sep 17 00:00:00 2001 From: Nathan Parsons Date: Mon, 30 Oct 2017 11:25:20 +0000 Subject: [PATCH 3/3] pig-latin: Fix example to work with new tests --- exercises/pig-latin/example.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/pig-latin/example.py b/exercises/pig-latin/example.py index d3f3a6e46d..f4b5ca575f 100644 --- a/exercises/pig-latin/example.py +++ b/exercises/pig-latin/example.py @@ -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]*')