Skip to content
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

pig-latin: add generator and update example #994

Merged
merged 5 commits into from
Jan 2, 2018
Merged

pig-latin: add generator and update example #994

merged 5 commits into from
Jan 2, 2018

Conversation

ilmanzo
Copy link
Contributor

@ilmanzo ilmanzo commented Dec 30, 2017

a part of #605.


//translate a sentence
Copy link
Contributor

Choose a reason for hiding this comment

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

please start with PigLatin for lint

}
return strings.Join(sw, " ")
}

//translates a single word
Copy link
Contributor

Choose a reason for hiding this comment

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

space after //

} else if x := cons.FindStringSubmatchIndex(s); x != nil {
result = s[x[3]:] + s[:x[3]] + "ay"
}
return
Copy link
Contributor

Choose a reason for hiding this comment

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

let's refactor naked return

t.Fatalf("PigLatin(%q) = %q, want %q.", test.in, pl, test.pl)
for _, test := range testCases {
if pl := PigLatin(test.input); pl != test.expected {
t.Fatalf("FAIL: %s\nPigLatin(%q) = %q, want %q.", test.description, test.input, pl, test.expected)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add a line of description for successful case ?

}

// Template to generate test cases.
var tmpl = `package igpay
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it was there before but what does it mean ? IMHO, better to make it piglatin and rename the functions to Sentence and Word. what do you think ?

Copy link
Contributor

@ferhatelmas ferhatelmas left a comment

Choose a reason for hiding this comment

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

Thanks ❤️

It's great but also see my inline comments to make it a bit better.

@ferhatelmas ferhatelmas changed the title implemented generator and new example for exercise pig-latin (ref issue #605) pig-latin: add generator and update example (closes #605) Dec 30, 2017
@ferhatelmas ferhatelmas changed the title pig-latin: add generator and update example (closes #605) pig-latin: add generator and update example Dec 30, 2017

func TestPigLatin(t *testing.T) {
for _, test := range testCases {
if pl := PigLatin(test.input); pl != test.expected {
t.Fatalf("FAIL: %s\nPigLatin(%q) = %q, want %q.", test.description, test.input, pl, test.expected)
fmt.Printf("Test: %s\n", test.description)
Copy link
Contributor

Choose a reason for hiding this comment

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

If test fails we will see it twice, let's write it after if and also we can write PASS instead of Test since we know it passed.

Copy link
Contributor

@ferhatelmas ferhatelmas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for updates.

@ferhatelmas ferhatelmas merged commit 02d88f3 into exercism:master Jan 2, 2018
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