-
Notifications
You must be signed in to change notification settings - Fork 533
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
io.circe.NoSpacesSortKeysPrinterSuite flakey spec #1911
Comments
in my opinion there is a problem with keys starting with whitespace it seems like JVM parser (JawnParser.parse) sorts this with whitespaces at beggining with JS parser (convertJsToJson(JSON.parse(input))) it outputs: its the same for '\t', ' ', '', '\n' |
@dseer0 If you want/need identical semantics, you can use the Jawn parser on JS. |
@armanbilge is there any reason jawn isnt the default parser on JS? or there's just no point in switching to jawn? |
@dseer0 The default parser on JS is Using Jawn on JS cannot be as performant because it will compile to pure JavaScript. It will also increase the size of your final JS bundle. I haven't measured these, so it may or may not be a big deal. So, it's a trade-off. The native |
@dseer0 we finally got some benchmarks for Jawn vs |
Fixes circe#1911 The `JSON.parse` call on native JS automatically and always sorts the keys when parsing, but slightly differently than the ordering prescribed by `Order[String]`. This causes tests on the sorted printers to fail under certain circumstances. The fix for this is to use Jawn on JS to get consistent parsing. If we switch to Jawn in general for both JS and the JVM then we can undo this. Note, the issue has never been with the printing, but always with the parsing.
On the JS run this test was seen failing. I haven't looked into it to se if it's related to JS or affects all and is just a good input to see a failure.
==> X io.circe.NoSpacesSortKeysPrinterSuite.Printer with sortKeys should sort the object keys 0.26s munit.FailException: /home/runner/work/circe/circe/modules/tests/shared/src/test/scala/io/circe/SortedKeysSuite.scala:30 assertion failed
29: val keys = parsed.keys.toVector
30: assert(keys.sorted === keys)
31: }
Failing seed: Q77xP9WJjYRbRkQLYsOsBNr-Ex78IBI9PAVcu7f3fZP=
You can reproduce this failure by adding the following override to your suite:
override val scalaCheckInitialSeed = "Q77xP9WJjYRbRkQLYsOsBNr-Ex78IBI9PAVcu7f3fZP="
Falsified after 88 passed tests.
The text was updated successfully, but these errors were encountered: