Skip to content

Commit

Permalink
Avoid test compilation issues on OTP 27
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed May 21, 2024
1 parent 54e0714 commit df84309
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/examples/fail_no_successive_maps.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

-export([bad/0, good/0]).

-if(?OTP_RELEASE<27).
bad() ->
M = #{this => is}#{wrong => "and"},
M2 = M#{this := is}#{wrong := "as well"},
M2#{this := is}#{also => wrong}.
-else.
bad() ->
#{}.
-endif.

-if(?OTP_RELEASE<27).
good() ->
M = #{this => is, good => "and"},
M2 = M#{this := is, good := #{as => well}},
M2#{this := is, also => good}.
-else.
good() ->
#{}.
-endif.
10 changes: 10 additions & 0 deletions test/examples/pass_no_successive_maps_elvis_attr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

-elvis([{elvis_style, no_successive_maps, disable}]).

-if(?OTP_RELEASE<27).
bad() ->
M = #{this => is}#{wrong => "and"},
M2 = M#{this := is}#{wrong := "as well"},
M2#{this := is}#{also => wrong}.
-else.
bad() ->
#{}.
-endif.

-if(?OTP_RELEASE<27).
good() ->
M = #{this => is, good => "and"},
M2 = M#{this := is, good := "as well"},
M2#{this := is, also => good}.
-else.
good() ->
#{}.
-endif.
9 changes: 9 additions & 0 deletions test/style_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,8 @@ verify_no_nested_try_catch(Config) ->
Path).

-spec verify_no_successive_maps(config()) -> any().
-if(?OTP_RELEASE < 27).

verify_no_successive_maps(Config) ->
Group = proplists:get_value(group, Config, erl_files),
Ext = proplists:get_value(test_file_ext, Config, "erl"),
Expand All @@ -1260,6 +1262,13 @@ verify_no_successive_maps(Config) ->
#{ignore => [Module]},
Path).

- else .

verify_no_successive_maps(_Config) ->
[].

-endif.

-spec verify_atom_naming_convention(config()) -> any().
verify_atom_naming_convention(Config) ->
Group = proplists:get_value(group, Config, erl_files),
Expand Down

0 comments on commit df84309

Please sign in to comment.