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

Tests Assuming maps:to_list/1 Order Are Failing #84

Closed
dw-kihara opened this issue May 26, 2024 · 2 comments · Fixed by #85
Closed

Tests Assuming maps:to_list/1 Order Are Failing #84

dw-kihara opened this issue May 26, 2024 · 2 comments · Fixed by #85

Comments

@dw-kihara
Copy link

The function maps:to_list/1 documentation states that it returns key-value pairs in an arbitrary order.
However, some tests assume a specific order and hard-code the resulting JSON with a definite order.
This causes the tests to fail when the order is different.

When I tried OTP27, the eunit tests failed as follows.

Test code (one example):

?assertEqual({ok, <<"{\"a\": 1, \"b\": 2}">>}, jsone_encode:encode(?OBJ2(a, 1, b, 2), [{space, 1}])),

Result:

...
  1) jsone_encode_tests:-encode_test_/0-anonymous-37-/0: space
     Failure/Error: ?assertEqual({ok,<<123,34,97,34,58,32,49,44,32,34,98,34,58,32,50,125>>}, jsone_encode : encode ( ? OBJ2 ( a , 1 , b , 2 ) , [ { space , 1 } ] ))
       expected: {ok,<<"{\"a\": 1, \"b\": 2}">>}
            got: {ok,<<"{\"b\": 2, \"a\": 1}">>}
     %% eunit_proc.erl:583:in `eunit_proc:run_group/2`
     Output:
     Output:
...

I'm sorry I don't know what is the best way to fix it, so I wrote this issue instead of writing a pull request.

@sile
Copy link
Owner

sile commented May 26, 2024

Thank you for creating this issue.
I'll fix the failures soon.

@dw-kihara
Copy link
Author

Thank you for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants