Skip to content

twelve-days: re-implement according to canonical data #1306

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 5 commits into from
Feb 20, 2018

Conversation

mrcfps
Copy link

@mrcfps mrcfps commented Feb 17, 2018

Closes #1221. Re-implement this exercise according to canonical data.

"a Partridge in a Pear Tree.\n\n"
class LyricsTests(unittest.TestCase):
def test_first_three_verses_of_the_song(self):
expected = ["On the first day of Christmas my true love gave to me, "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are other tests verifying correct output from recite(n, n), I think the following would be adequate:

expected = [recite(n, n) for n in range(1, 4)]

This also removes the need for large redundant text blocks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmccandless Pretty nice trick! But since recite returns a list of one string, we should capture its first element:

expected = [recite(n, n)[0] for n in range(1, 4)]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the idea of nice tricks...

expected = sum([recite(n, n) for n in range(1, 4)], [])

Not really any neater than what you're already doing, and it's not as readable, so please don't use that for this exercise.

self.assertEqual(recite(1, 3), expected)

def test_three_verses_from_the_middle_of_the_song(self):
expected = ["On the fourth day of Christmas my true love gave to me, "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, expected = [recite(n, n) for n in range(4, 7)]


def test_the_whole_song(self):
self.assertEqual(verses(1, 12), sing())
expected = ["On the first day of Christmas my true love gave to me, "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, expected = [recite(n, n) for n in range(1, 13)]

@cmccandless cmccandless merged commit d2d7106 into exercism:master Feb 20, 2018
@mrcfps mrcfps deleted the twelve-days-1221 branch February 26, 2018 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants