Skip to content

OTP 26 test failure #17

@ckampfe

Description

@ckampfe

On OTP 26 (both Elixir 1.14.5 and 1.15.0) I'm getting this test failure:

  1) test create attribute string from map (SneezeInternalTest)
     test/sneeze_test.exs:186
     Assertion with == failed
     code:  assert Internal.attributes_to_iolist(%{class: "foo", id: "bar"}) == [
              [" ", "class", "=\"", "foo", "\""],
              [" ", "id", "=\"", "bar", "\""]
            ]
     left:  [
              [" ", "id", "=\"", "bar", "\""],
              [" ", "class", "=\"", "foo", "\""]
            ]
     right: [
              [" ", "class", "=\"", "foo", "\""],
              [" ", "id", "=\"", "bar", "\""]
            ]
     stacktrace:
       test/sneeze_test.exs:187: (test)

............................
Finished in 0.06 seconds (0.00s async, 0.06s sync)
30 tests, 1 failure

Randomized with seed 682196

which I believe is due to the (implicit) assumption that the map arg (%{class: "foo", id: "bar"}) will be iterated first by the class key and then the id key.

I believe this assumption which was previously valid is no longer valid because in the OTP team in OTP 26 made an optimization to maps which changed the iteration order of maps from being by the term order of the keys to being undefined:
"The new order is undefined and may change between different invocations of the Erlang VM." (https://www.erlang.org/blog/otp-26-highlights/#changed-ordering-of-atom-keys)

I've previously run into issues like this, and solved them by comparing the collections as sets (MapSet.equal?(s1, s2)) rather than lists, if order is not important. I'm happy to PR this change if you want it or discuss further if you have other ideas.

Thanks again for your efforts on this library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions