diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-05-09 17:59:12 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-05-09 17:59:12 +0200 |
commit | 1c817ecd054780551bcbe8b5a0e30bea2b3da04e (patch) | |
tree | e1a57c1592b3662cc785f4770e210140593a9986 /lib/hipe/test/maps_SUITE_data/maps_update_values.erl | |
parent | 659213c7facb71410fe990d5099abf3019c58b3e (diff) | |
parent | f6d5234c391a0ba834337c3e92ee5fb377834a32 (diff) | |
download | otp-1c817ecd054780551bcbe8b5a0e30bea2b3da04e.tar.gz otp-1c817ecd054780551bcbe8b5a0e30bea2b3da04e.tar.bz2 otp-1c817ecd054780551bcbe8b5a0e30bea2b3da04e.zip |
Merge branch 'ks/hipe-map-support/OTP-11900' into maint
* ks/hipe-map-support/OTP-11900:
Add five new test files for maps in the HiPE test suite
Copy the tests for maps from the compiler application to a new HiPE test suite
Translate the put_map_assoc and put_map_exact BEAM instructions to ICode
Translate the has_map_fields and get_map_elements BEAM instructions to ICode
Diffstat (limited to 'lib/hipe/test/maps_SUITE_data/maps_update_values.erl')
-rw-r--r-- | lib/hipe/test/maps_SUITE_data/maps_update_values.erl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/hipe/test/maps_SUITE_data/maps_update_values.erl b/lib/hipe/test/maps_SUITE_data/maps_update_values.erl new file mode 100644 index 0000000000..bbad5ac19e --- /dev/null +++ b/lib/hipe/test/maps_SUITE_data/maps_update_values.erl @@ -0,0 +1,28 @@ +-module(maps_update_values). +-export([test/0]). + +test() -> + V0 = id(1337), + M0 = #{ a => 1, val => V0}, + V1 = get_val(M0), + M1 = M0#{ val := [V0,V1], "wazzup" => 42 }, + [1337, {some_val, 1337}] = get_val(M1), + + N = 110, + List = [{[I,1,2,3,I],{1,2,3,"wat",I}}|| I <- lists:seq(1,N)], + + {_,_,#{val2 := {1,2,3,"wat",N}, val1 := [N,1,2,3,N]}} = lists:foldl(fun + ({V2,V3},{Old2,Old3,Mi}) -> + ok = check_val(Mi,Old2,Old3), + #{ val1 := Old2, val2 := Old3 } = Mi, + {V2,V3, Mi#{ val1 := id(V2), val2 := V1, val2 => id(V3)}} + end, {none, none, #{val1=>none,val2=>none}},List), + ok. + +get_val(#{ "wazzup" := _, val := V}) -> V; +get_val(#{ val := V }) -> {some_val, V}. + +check_val(#{val1:=V1, val2:=V2},V1,V2) -> ok. + +%% Use this function to avoid compile-time evaluation of an expression. +id(I) -> I. |