Skip to content

Commit 3ffdec8

Browse files
committed
Updated tests to not use tuple function applcation.
OTP 21 removed erlang:apply/3's ability to take a tuple as the first argument, so the tests that used the functionality have been refactored to no rely on it. the functionality is now tested behind an ifdef/if >= for the otp version 21.
1 parent ddc4fe1 commit 3ffdec8

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

test/default_value_tests.erl

+32-4
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,39 @@ defaults_test_() ->
6363
],
6464

6565
lists:map(fun({Field, Value}) ->
66-
Name = iolist_to_binary(io_lib:format("ensure ~p is ~p", [Field, Value])),
67-
{Name, fun() ->
68-
?assertEqual(Value, erlang:apply(Rec, Field, []))
69-
end}
66+
create_default_test(Field, Value, Rec)
7067
end, Expectations).
7168

69+
-ifdef(OTP_RELEASE).
70+
71+
-if(?OTP_RELEASE >= 21).
72+
73+
create_default_test(Field, Value, Rec) ->
74+
Name = iolist_to_binary(io_lib:format("ensure ~p is ~p", [Field, Value])),
75+
{Name, fun() ->
76+
?assertEqual(Value, erlang:apply(?MODULE, Field, [Rec]))
77+
end}.
78+
79+
-else.
80+
81+
create_default_test(Field, Value, Rec) ->
82+
Name = iolist_to_binary(io_lib:format("ensure ~p is ~p", [Field, Value])),
83+
{Name, fun() ->
84+
?assertEqual(Value, erlang:apply(?MODULE, Field, [Rec])),
85+
?assertEqual(Value, erlang:apply(Rec, Field, []))
86+
end}.
87+
88+
-endif.
89+
90+
-else.
91+
92+
create_default_test(Field, Value, Rec) ->
93+
Name = iolist_to_binary(io_lib:format("ensure ~p is ~p", [Field, Value])),
94+
{Name, fun() ->
95+
?assertEqual(Value, erlang:apply(?MODULE, Field, [Rec])),
96+
?assertEqual(Value, erlang:apply(Rec, Field, []))
97+
end}.
98+
7299
-endif.
73100

101+
-endif.

0 commit comments

Comments
 (0)