Skip to content

Commit

Permalink
Solve map ordering in earlier Erlang/OTP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 17, 2024
1 parent a8c9206 commit 0174d50
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions lib/ex_unit/test/ex_unit/diff_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -879,30 +879,28 @@ defmodule ExUnit.DiffTest do

test "maps in lists" do
map = %{
address: %{
street: "123 Main St",
city: "Springfield",
state: "IL",
zip: "62701"
"address" => %{
"street" => "123 Main St",
"zip" => "62701"
},
age: 30,
first_name: "John",
language: "en-US",
last_name: "Doe",
notifications: true
"age" => 30,
"first_name" => "John",
"language" => "en-US",
"last_name" => "Doe",
"notifications" => true
}

refute_diff(
[map] == [],
"""
[
-%{
address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
age: 30,
first_name: "John",
language: "en-US",
last_name: "Doe",
notifications: true
"address" => %{"street" => "123 Main St", "zip" => "62701"},
"age" => 30,
"first_name" => "John",
"language" => "en-US",
"last_name" => "Doe",
"notifications" => true
}-
]\
""",
Expand All @@ -915,12 +913,12 @@ defmodule ExUnit.DiffTest do
"""
[
+%{
address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
age: 30,
first_name: "John",
language: "en-US",
last_name: "Doe",
notifications: true
"address" => %{"street" => "123 Main St", "zip" => "62701"},
"age" => 30,
"first_name" => "John",
"language" => "en-US",
"last_name" => "Doe",
"notifications" => true
}+
]\
"""
Expand All @@ -932,10 +930,8 @@ defmodule ExUnit.DiffTest do
test "structs in lists" do
customer = %Customer{
address: %{
street: "123 Main St",
city: "Springfield",
state: "IL",
zip: "62701"
"street" => "123 Main St",
"zip" => "62701"
},
age: 30,
first_name: "John",
Expand All @@ -949,7 +945,7 @@ defmodule ExUnit.DiffTest do
"""
[
-%ExUnit.DiffTest.Customer{
address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
address: %{"street" => "123 Main St", "zip" => "62701"},
age: 30,
first_name: "John",
language: "en-US",
Expand All @@ -967,7 +963,7 @@ defmodule ExUnit.DiffTest do
"""
[
+%ExUnit.DiffTest.Customer{
address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
address: %{"street" => "123 Main St", "zip" => "62701"},
age: 30,
first_name: "John",
language: "en-US",
Expand Down

0 comments on commit 0174d50

Please sign in to comment.