From 9a141faf47bd92559e13ed7911a5e06a827b0499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=B6m=C3=B6ri?= Date: Fri, 22 Dec 2023 00:51:10 +0100 Subject: [PATCH] Skip test of maybe expr/map compr if not supported by OTP version --- apps/els_lsp/test/els_parser_SUITE.erl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/els_lsp/test/els_parser_SUITE.erl b/apps/els_lsp/test/els_parser_SUITE.erl index 2405a769b..edee64718 100644 --- a/apps/els_lsp/test/els_parser_SUITE.erl +++ b/apps/els_lsp/test/els_parser_SUITE.erl @@ -4,7 +4,8 @@ -export([ all/0, init_per_suite/1, - end_per_suite/1 + end_per_suite/1, + init_per_testcase/2 ]). %% Test cases @@ -33,6 +34,7 @@ record_def_recursive/1, var_in_application/1, comprehensions/1, + map_comprehensions/1, maybe_expr/1, unicode_clause_pattern/1, latin1_source_code/1, @@ -62,6 +64,23 @@ end_per_suite(_Config) -> ok. -spec all() -> [atom()]. all() -> els_test_utils:all(?MODULE). +init_per_testcase(map_comprehensions, Config) -> + case list_to_integer(erlang:system_info(otp_release)) < 26 of + true -> + {skip, "Map comprehensions are only supported from OTP 26"}; + false -> + Config + end; +init_per_testcase(maybe_expr, Config) -> + case list_to_integer(erlang:system_info(otp_release)) < 25 of + true -> + {skip, "Maybe expressions are only supported from OTP 25"}; + false -> + Config + end; +init_per_testcase(_, Config) -> + Config. + %%============================================================================== %% Testcases %%============================================================================== @@ -456,7 +475,9 @@ comprehensions(_Config) -> [#{id := 'Y'}, #{id := 'X'}, #{id := 'X'}, #{id := 'Y'}, #{id := 'B'}], parse_find_pois(Text2, variable) ), + ok. +map_comprehensions(_Config) -> Text3 = "#{ Y => X || X := Y <- M }", ?assertMatch( [#{id := 'Y'}, #{id := 'X'}, #{id := 'X'}, #{id := 'Y'}, #{id := 'M'}],