go-linq icon indicating copy to clipboard operation
go-linq copied to clipboard

Unit test ExampleOrderedQuery_ThenByDescending fails on golang-1.19.2

Open sdgathman opened this issue 2 years ago • 6 comments

      testing: github.com/ahmetb/go-linq
github.com/ahmetb/go-linq
--- FAIL: ExampleOrderedQuery_ThenByDescending (0.00s)
got:
apPLe
apple
apPLE
APple
orange
baNanA
ORANGE
BAnana
want:
apPLe
apPLE
apple
APple
orange
baNanA
ORANGE
BAnana
FAIL
exit status 1
FAIL	github.com/ahmetb/go-linq	0.021s

sdgathman avatar Nov 23 '22 18:11 sdgathman

Passes on golang-1.18

sdgathman avatar Nov 23 '22 18:11 sdgathman

Interesting. If you wanna debug, I'm open to patches.

ahmetb avatar Nov 23 '22 18:11 ahmetb

Probably related to the change in sorting algorithm to pattern-defeating quicksort in Go 1.19.

https://tip.golang.org/doc/go1.19#sort

neilalexander avatar Nov 23 '22 19:11 neilalexander

I'm not a go programmer, but you'd think there would be a sort_unstable() to get the faster algorithm rather than breaking a bunch of things that depend on stability.

sdgathman avatar Nov 23 '22 20:11 sdgathman

Since this package seems to be about linking to case insensitive libraries, the result might be actually valid. But the verbatim check is too strict for an unstable sort. How about running the output through an undependent stable sort (e.g. unix sort program with case insensitive option) and check that the result is unchanged? Would that be valid?

sdgathman avatar Nov 23 '22 20:11 sdgathman

I'm not a go programmer, but you'd think there would be a sort_unstable() to get the faster algorithm rather than breaking a bunch of things that depend on stability.

There is probably already some difference between sort.Sort and sort.Stable.

neilalexander avatar Nov 23 '22 20:11 neilalexander