Skip to content

Commit 3532c37

Browse files
authored
Merge pull request #31 from lordnull/mw-support-erl-21
Support erl 21
2 parents 740d502 + f079a03 commit 3532c37

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: erlang
22
otp_release:
3+
- 21.0
34
- 20.0
45
- 19.0
56

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROJECT = rec2json
22
PROJECT_DESCRIPTION = Compile erlang record definitions into modules to convert them to/from json easily.
3-
PROJECT_VERSION = 4.0.0
3+
PROJECT_VERSION = 4.0.1
44

55
TEST_DEPS = proper jsx
66
dep_proper = git https://github.com/manopapad/proper master

ebin/rec2json.app

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{application, rec2json, [
22
{description, "Compile erlang record definitions into modules to convert them to/from json easily."},
3-
{vsn, "4.0.0"},
3+
{vsn, "4.0.1"},
44
{modules, ['r2j_compile','r2j_type','rec2json']},
55
{registered, []},
66
{applications, [kernel,stdlib]}
7-
]}.
7+
]}.

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)