@@ -10,6 +10,10 @@ defmodule ExUnit.DiffTest do
1010 defstruct [ :name , :age ]
1111 end
1212
13+ defmodule Customer do
14+ defstruct [ :address , :age , :first_name , :language , :last_name , :notifications ]
15+ end
16+
1317 defmodule Person do
1418 defstruct [ :age ]
1519 end
@@ -875,30 +879,30 @@ defmodule ExUnit.DiffTest do
875879
876880 test "maps in lists" do
877881 map = % {
878- first_name: "John" ,
879- last_name: "Doe" ,
880- age: 30 ,
881- notifications: true ,
882- language: "en-US" ,
883882 address: % {
884883 street: "123 Main St" ,
885884 city: "Springfield" ,
886885 state: "IL" ,
887886 zip: "62701"
888- }
887+ } ,
888+ age: 30 ,
889+ first_name: "John" ,
890+ language: "en-US" ,
891+ last_name: "Doe" ,
892+ notifications: true
889893 }
890894
891895 refute_diff (
892896 [ map ] == [ ] ,
893897 """
894898 [
895899 -%{
896- address: %{state: \ " IL\ " , zip: \ " 62701\ " , street: \ " 123 Main St\ " , city: \ " Springfield\ " },
900+ address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
897901 age: 30,
898- first_name: \ " John\ " ,
899- last_name: \" Doe \ " ,
900- notifications: true ,
901- language: \" en-US \"
902+ first_name: "John",
903+ language: "en-US ",
904+ last_name: "Doe" ,
905+ notifications: true
902906 }-
903907 ]\
904908 """ ,
@@ -911,12 +915,12 @@ defmodule ExUnit.DiffTest do
911915 """
912916 [
913917 +%{
914- address: %{state: \ " IL\ " , zip: \ " 62701\ " , street: \ " 123 Main St\ " , city: \ " Springfield\ " },
918+ address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
915919 age: 30,
916- first_name: \ " John\ " ,
917- last_name: \" Doe \ " ,
918- notifications: true ,
919- language: \" en-US \"
920+ first_name: "John",
921+ language: "en-US ",
922+ last_name: "Doe" ,
923+ notifications: true
920924 }+
921925 ]\
922926 """
@@ -925,6 +929,58 @@ defmodule ExUnit.DiffTest do
925929 assert_diff ( [ map ] == [ map ] , [ ] )
926930 end
927931
932+ test "structs in lists" do
933+ customer = % Customer {
934+ address: % {
935+ street: "123 Main St" ,
936+ city: "Springfield" ,
937+ state: "IL" ,
938+ zip: "62701"
939+ } ,
940+ age: 30 ,
941+ first_name: "John" ,
942+ language: "en-US" ,
943+ last_name: "Doe" ,
944+ notifications: true
945+ }
946+
947+ refute_diff (
948+ [ customer ] == [ ] ,
949+ """
950+ [
951+ -%ExUnit.DiffTest.Customer{
952+ address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
953+ age: 30,
954+ first_name: "John",
955+ language: "en-US",
956+ last_name: "Doe",
957+ notifications: true
958+ }-
959+ ]\
960+ """ ,
961+ "[]"
962+ )
963+
964+ refute_diff (
965+ [ ] == [ customer ] ,
966+ "[]" ,
967+ """
968+ [
969+ +%ExUnit.DiffTest.Customer{
970+ address: %{state: "IL", zip: "62701", street: "123 Main St", city: "Springfield"},
971+ age: 30,
972+ first_name: "John",
973+ language: "en-US",
974+ last_name: "Doe",
975+ notifications: true
976+ }+
977+ ]\
978+ """
979+ )
980+
981+ assert_diff ( [ customer ] == [ customer ] , [ ] )
982+ end
983+
928984 test "maps and structs with escaped values" do
929985 refute_diff (
930986 % User { age: { 1 , 2 , 3 } } = % User { age: { 1 , 2 , 4 } } ,
0 commit comments