Closed kwiat1990 closed 3 years ago
I've had a similar experience when working through the exercises.
The Card Tricks
exercise stands out because it also seems to jump between tests for GetItem
and SetItem
.
This (wrong) solution results in the next error being about TestSetItem
:
// GetItem retrieves an item from a slice at given position. The second return value indicates whether
// a the given index existed in the slice or not.
func GetItem(slice []int, index int) (int, bool) {
if len(slice) > index - 1 {
return 0, false
} else {
return slice[index], true
}
}
// SetItem writes an item to a slice at given position overwriting an existing value.
// If the index is out of range it is be appended.
func SetItem(slice []int, index, value int) []int {
panic("")
}
However, when I change SetItem
, the next error displayed is about GetItem
again:
// GetItem retrieves an item from a slice at given position. The second return value indicates whether
// a the given index existed in the slice or not.
func GetItem(slice []int, index int) (int, bool) {
if len(slice) > index - 1 {
return 0, false
} else {
return slice[index], true
}
}
// SetItem writes an item to a slice at given position overwriting an existing value.
// If the index is out of range it is be appended.
func SetItem(slice []int, index, value int) []int {
if len(slice) > index - 1 {
slice = append(slice, value)
} else {
slice[index] = value
}
return slice
}
I know these are wrong but I'm confused by the order and interaction of tests.
In addition to what you describe, I was also confused by the number of tests passing/failing changing.
For example, in the Card Tricks
exercise, the following function results in 3 tests passed, 2 failed
:
func GetItem(slice []int, index int) (int, bool) {
return slice[index], true
}
Changing the function to the following, the numbers change to 2 tests passed, 6 failed
:
func GetItem(slice []int, index int) (int, bool) {
if len(slice) > index - 1 {
return 0, false
} else {
return slice[index], true
}
}
In the Annalyn exercise, something similar happens. With only the first function implemented, it shows "3 tests passed, 2 tests failed". After implementing the second function, it switches to "10 tests passed, 2 tests failed". Where do these tests suddenly come from? This makes it hard to keep track of which tests are actually passing and which aren't.
(Perhaps this should be split into an issue about that exercise in particular, but I think it works as an example for this issue too.)
I am interpreting this issue as a general confusion about failure messages, as @kwiat1990 reported. However @SaschaMann reported two related, but more specific issue, that I myself also experienced, and I opened separate issues for them.
Perhaps this should be split into an issue about that exercise in particular
I experienced very similar issues for a different exercise - Cars Assemble
The Card Tricks exercise stands out because it also seems to jump between tests for GetItem and SetItem.
I created a separate issue for the random order: https://github.com/exercism/go-test-runner/issues/46
With only the first function implemented, it shows "3 tests passed, 2 tests failed". After implementing the second function, it switches to "10 tests passed, 2 tests failed".
I created a separate issue for this: https://github.com/exercism/go-test-runner/issues/47
I am closing this issue because everything mentioned in here is covered in other issues. The original issue is covered in #8.
Hi, I've recently pick up Go on Exercism and one by one I try to go through all exercises. The web editor is great for this purpose but what's bother me, and I think also slows down quite a bit, are tests which failed. I feel like the messages are not clear enough and in some tests one doesn't even know what exactly failed.
An example of such test would be following output - in this case the "failure" description is completely missing and by single test case it would be helpful if there is also
got
key or something like this, which would hold returned value:If I'm missing something or read provided output wrong please let me know.