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

Improvement idea for Diamond tests #2222

Closed
rootulp opened this issue May 25, 2022 · 1 comment · Fixed by #2255
Closed

Improvement idea for Diamond tests #2222

rootulp opened this issue May 25, 2022 · 1 comment · Fixed by #2255
Labels
x:action/improve Improve existing functionality/content x:knowledge/none No existing Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:size/medium Medium amount of work x:type/content Work on content (e.g. exercises, concepts)

Comments

@rootulp
Copy link
Contributor

rootulp commented May 25, 2022

While solving the Diamond exercise, I had a difficult time iteratively solving the exercise because diamond_test.go is all or nothing. In other words, the entire solution is implemented and all tests pass or the solution isn't implemented and all tests fail.

While solving, I found it helpful to iteratively solve against test cases like:

func TestDiamond(t *testing.T) {
	tests := []test{
		{'A', "A\n"},
		{'B', " A \nB B\n A \n"},
		{'C', "  A  \n B B \nC   C\n B B \n  A  \n"},
		{'D', "   A   \n  B B  \n C   C \nD     D\n C   C \n  B B  \n   A   \n"},
	}
	for _, test := range tests {
		got, err := Gen(byte(test.input))

		if err != nil {
			t.Errorf("Gen(byte(%v)) err %v", test.input, err)
		}
		if got != test.want {
			t.Errorf("Gen(byte(%v) got\n%v want\n%v", test.input, got, test.want)
		}
	}
}

If maintainers are open to a test like the above being added to the exercise, I think it could help future solvers and I'm happy to create a PR for it.

rootulp added a commit to rootulp/exercism that referenced this issue May 25, 2022
@andrerfcsantos
Copy link
Member

Hi!

Thanks for opening an issue about this.

The instructions and test cases come from the problem-specifications repo. The test cases for this exercise are in canonical-data.json.

It seems that Go decided to not use the test cases in the problem specs repo for this exercise and instead implemented property-based testing. However, you raise a good point and I think that value-based tests like the ones in the canonical.json file can help arrive at a solution.

So, my suggestion here would be to add the tests in canonical-data.json to the tests we already have.

@andrerfcsantos andrerfcsantos added x:action/improve Improve existing functionality/content x:knowledge/none No existing Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/medium Medium amount of work labels May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/improve Improve existing functionality/content x:knowledge/none No existing Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:size/medium Medium amount of work x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants