Add tests to pig-latin exercise

Example solutions for practice exercises only prove that a test suite as currently written for a language can be solved for continuous integration purposes. I wouldn’t read too much into what one particular example solution is doing as a result. Some maintainers do prefer polished and idiomatic example solutions, but that’s in no way expected across the board as long as the test suite CI passes.

I do not suggest to change example solution, but the tests are not complete and they need to be refined.

Or you think that quick afternoonay run is the correct translation? One could expect ickquay afternoonay unray instead.

We could even add “quick afternoon run” as reimplementantation of “quick fast run” with explaination “‘quick fast run’ does not test when words starting with consonants and words starting with vowels are mixed together”

And then let maintainers decide. If they choose not to use reimplementantation, that is perfectly fine, but it is good to have options.

Would you mind explaining why it matters if a multi word solution has a middle word starting with a vowel? Most of the solutions I’ve seen split input into words and process each word. If they can handle the single word cases starting with vowels, the sentence version should behave the same. I’m not understanding what this change would accomplish.

1 Like

When the word in the middle starts with vowel, the “ickquay” and “unray” words turns into untranslated “quick” and “run” respectively.

This is why it matters.

We could replace the "quick fast run" test case with "my quick afternoon xray scan"

This covers all four rules, including two forms of the first rule. It also includes a starting consonant pattern that is not detected by solutions that may have been written for older versions of the instructions.

2 Likes

Could you explain why that might happen? If words are split and translated, I don’t see why middle words would be different than initial words. If middle words are not translated properly, why would words starting with a consonant be different from words starting with a vowel. You are stating they are different but I’m not hearing a why.

I think the F# example solution checks if the string contains any word satisfying rule 1. If so, only rule 1 is ever applied.

If words were split and translated independently, in all student solutions, the existing test case would suffice.

That seems like a pretty poor implementation if you’re checking all words to transform one word :eyes:

This may happen because not all solutions use split and translate. This is why.

I am going to give up on space-preserving test because I haven’t seen any interest on this one.

But can prepare a pull request to add my first extra test or keraville’s test as reimplementantation of “quick fast run” test if you find this appropriate.

IsaacG, the example solution transforms all words, not just one, it just picks a wrong (vowel) pattern to translate them, and that pattern doesn’t work on words starting with consonants.

On the contrary, one can say that the example solution checks for one word to translate all words.

Please do not open any PRs until you have buy in of at least three maintainers.

keiraville proposed a multi-word test that contains all rules in one test. That should be used to replace the existing phrase test. Whitespace should not be added.

1 Like

Understood.

A short summary of discussion:

What is discussed

While mentioning a student’s solution, I noticed that his/her solution makes a wrong assumption that phrase always consists of words with the same type (all words starting with consonants or all words starting with vowels).

Then I tried to lead student towards a canonical solution, but to my suprise, the canonical solution have the same bug.

Why this happened

Almost all tests in the suite tests a single word (for which the incorrect assumption that phrase always contains words of one type always holds). Due to the unfortunate decision the only test that contains several words contain only words of the same type (the ones starting with consonants).

A proposal

To help students catch the bug, a test is proposed which contains not only words starting with consonants, but also words starting with vowels. This helps to ensure that the decision for each word is taken individually, not like “oh, I see a word starting with vowel, let us translate all words using a vowel pattern”, or the same assumption for consonants.

Here are proposed variants:

"quick afternoon run"
"my quick afternoon xray scan"

(keraville)

Both variants contain words of both kinds, so they should help to catch the bug.

"why do squids enjoy xrays" => "ywhay oday idssquay enjoyay xraysay"

;)

4 Likes

Hey nice :)

+1 for “why do squids enjoy xrays”

+1 from me, too

IsaacG, taking into account there is already at least three maintainers in the thread, we probably can come to consensus now?

Two explicit approvals and two implicit.
I’ll give a +1 here so there are three explicit approvals. Please do open a PR!

2 Likes