Skip to content

Commit 7914511

Browse files
committed
CI: Test OTP29 multi value comprehension
https://ampcode.com/threads/T-019c756b-07dd-745f-86c2-c609e54a434b Signed-off-by: Peter M <petermm@gmail.com>
1 parent 3ad4951 commit 7914511

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

tests/erlang_tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ compile_erlang(test_lists_member)
621621
compile_erlang(test_lists_keymember)
622622
compile_erlang(test_lists_keyfind)
623623

624+
compile_erlang(test_multi_value_comprehension)
625+
624626
if(Erlang_VERSION VERSION_GREATER_EQUAL "23")
625627
set(OTP23_OR_GREATER_TESTS
626628
test_op_bs_start_match_asm.beam
@@ -1152,6 +1154,8 @@ set(erlang_test_beams
11521154
bigint.beam
11531155
bigint_stress.beam
11541156

1157+
test_multi_value_comprehension.beam
1158+
11551159
${OTP23_OR_GREATER_TESTS}
11561160
${OTP25_OR_GREATER_TESTS}
11571161
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
%
2+
% This file is part of AtomVM.
3+
%
4+
% Copyright 2025 Peter Madsen-Mygdal
5+
%
6+
% Licensed under the Apache License, Version 2.0 (the "License");
7+
% you may not use this file except in compliance with the License.
8+
% You may obtain a copy of the License at
9+
%
10+
% http://www.apache.org/licenses/LICENSE-2.0
11+
%
12+
% Unless required by applicable law or agreed to in writing, software
13+
% distributed under the License is distributed on an "AS IS" BASIS,
14+
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
% See the License for the specific language governing permissions and
16+
% limitations under the License.
17+
%
18+
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
19+
%
20+
21+
-module(test_multi_value_comprehension).
22+
23+
-export([start/0]).
24+
25+
%% Test multi-valued comprehensions (EEP 78, OTP 29+)
26+
27+
-ifdef(OTP_RELEASE).
28+
-if(?OTP_RELEASE >= 29).
29+
-define(OTP29_OR_LATER, true).
30+
-endif.
31+
-endif.
32+
33+
-ifdef(OTP29_OR_LATER).
34+
35+
start() ->
36+
ok = test_basic_multi_value(),
37+
ok = test_single_value(),
38+
ok = test_multi_value_with_filter(),
39+
ok = test_multi_value_binary_comprehension(),
40+
0.
41+
42+
test_basic_multi_value() ->
43+
[-1, 1, -2, 2, -3, 3] = [-I, I || I <- [1, 2, 3]],
44+
ok.
45+
46+
test_single_value() ->
47+
[1, 2, 3] = [I || I <- [1, 2, 3]],
48+
ok.
49+
50+
test_multi_value_with_filter() ->
51+
[-2, 2] = [-I, I || I <- [1, 2, 3], I rem 2 =:= 0],
52+
ok.
53+
54+
test_multi_value_binary_comprehension() ->
55+
<<1, 2, 3, 4>> = <<<<I, (I + 1)>> || I <- [1, 3]>>,
56+
ok.
57+
58+
-else.
59+
60+
start() ->
61+
0.
62+
63+
-endif.

tests/test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ struct Test tests[] = {
557557

558558
TEST_CASE(test_op_bs_start_match),
559559
TEST_CASE(test_op_bs_create_bin),
560+
TEST_CASE(test_multi_value_comprehension),
560561

561562
TEST_CASE(test_code_server_nifs),
562563

0 commit comments

Comments
 (0)