Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/pmod_pt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ expr({bc,Line,E0,Qs0},St) ->
expr({tuple,Line,Es0},St) ->
Es1 = expr_list(Es0,St),
{tuple,Line,Es1};
expr({map, Line, Es0}, St) ->
Es1 = expr_list(Es0, St),
{map, Line, Es1};
expr({map, Line, OldMap0, Es0}, St) ->
OldMap1 = expr(OldMap0, St),
Es1 = expr_list(Es0, St),
{map, Line, OldMap1, Es1};
expr({map_field_assoc, Line, Key0, Val0}, St) ->
Key1 = expr(Key0, St),
Val1 = expr(Val0, St),
{map_field_assoc, Line, Key1, Val1};
expr({map_field_exact, Line, Key0, Val0}, St) ->
Key1 = expr(Key0, St),
Val1 = expr(Val0, St),
{map_field_exact, Line, Key1, Val1};
expr({record_index,_,_,_}=RI, _St) ->
RI;
expr({record,Line,Name,Is0},St) ->
Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ MODULES = \
pmod_basic.beam \
my_lists.beam \
static_call.beam \
fun_in_pmod.beam
fun_in_pmod.beam \
map_test.beam

EBIN = $(dir $(CURDIR))ebin

Expand Down
29 changes: 29 additions & 0 deletions tests/map_test.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%
-include_lib("pmod_transform/include/pmod.hrl").

-module(map_test, [M]).

-export([add/2, update/2]).

add(Key, Val) ->
new(M#{Key => Val}).

update(Key, Val) ->
new(M#{Key := Val}).
5 changes: 5 additions & 0 deletions tests/test_pmod.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ record_index_test() ->

record_index_match({#r.a,#r.b,#r.c}) ->
ok.

map_test() ->
M0 = map_test:new(#{}),
M1 = M0:add(a, 1),
M1:update(a, 2).