aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test/inline_SUITE_data
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-11-05 15:42:27 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-01-28 15:56:28 +0100
commit1014059ea438798960cf858e6f37b16e321152ad (patch)
treeaf55d347c1a99bb5bb5098ff52c9a68dc3c2d817 /lib/compiler/test/inline_SUITE_data
parentd4379900790b37498fefa237cd03ab2d5781bb6a (diff)
downloadotp-1014059ea438798960cf858e6f37b16e321152ad.tar.gz
otp-1014059ea438798960cf858e6f37b16e321152ad.tar.bz2
otp-1014059ea438798960cf858e6f37b16e321152ad.zip
compiler: Test Maps inlining
Diffstat (limited to 'lib/compiler/test/inline_SUITE_data')
-rw-r--r--lib/compiler/test/inline_SUITE_data/maps_inline_test.erl60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/compiler/test/inline_SUITE_data/maps_inline_test.erl b/lib/compiler/test/inline_SUITE_data/maps_inline_test.erl
new file mode 100644
index 0000000000..87a8f86b47
--- /dev/null
+++ b/lib/compiler/test/inline_SUITE_data/maps_inline_test.erl
@@ -0,0 +1,60 @@
+%%
+%% %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%
+%%
+
+-module(maps_inline_test).
+
+-export([?MODULE/0]).
+
+?MODULE() ->
+ 21 = mval(#{val => 1}) +
+ mval(#{val => 2}) +
+ mval(#{val => 3}) +
+ mval(#{val => 4}) +
+ mval(#{val => 5}) +
+ mval(#{val => 6}),
+
+ 21 = gval(#{id => 1}) +
+ gval(#{id => 2}) +
+ gval(#{id => 3}) +
+ gval(#{id => 4}) +
+ gval(#{id => 5}) +
+ gval(#{id => 6}),
+
+ 21 = sval(#{id => 1}) +
+ sval(#{id => 2}) +
+ sval(#{id => 3}) +
+ sval(#{id => 4}) +
+ sval(#{id => 5}) +
+ sval(#{id => 6}).
+
+mval(#{val := V}) -> V.
+
+sval(#{id := 1}) -> 6;
+sval(#{id := 2}) -> 5;
+sval(#{id := 3}) -> 4;
+sval(#{id := 4}) -> 3;
+sval(#{id := 5}) -> 2;
+sval(#{id := 6}) -> 1.
+
+gval(M) when is_map(M) andalso M =:= #{ id => 1} -> 1;
+gval(M) when is_map(M) andalso M =:= #{ id => 2} -> 4;
+gval(M) when is_map(M) andalso M =:= #{ id => 3} -> 2;
+gval(M) when is_map(M) andalso M =:= #{ id => 4} -> 5;
+gval(M) when is_map(M) andalso M =:= #{ id => 5} -> 3;
+gval(M) when is_map(M) andalso M =:= #{ id => 6} -> 6.