aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/maps_SUITE_data/maps_update_exact.erl
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2014-03-26 18:58:46 +0100
committerKostis Sagonas <[email protected]>2014-04-29 11:40:29 +0200
commit5a43eb383bdeb604fd8a891ffe34610c3fe6208b (patch)
tree1a76c9a5bf0d8f32c06acb8266eaa52ce6e860d5 /lib/hipe/test/maps_SUITE_data/maps_update_exact.erl
parente486d8b0c6124f39db6fa600f348c7bd5c0c1a13 (diff)
downloadotp-5a43eb383bdeb604fd8a891ffe34610c3fe6208b.tar.gz
otp-5a43eb383bdeb604fd8a891ffe34610c3fe6208b.tar.bz2
otp-5a43eb383bdeb604fd8a891ffe34610c3fe6208b.zip
Copy the tests for maps from the compiler application to a new HiPE test suite
Change the maps_guard_fun test to accept the HiPE trace format.
Diffstat (limited to 'lib/hipe/test/maps_SUITE_data/maps_update_exact.erl')
-rw-r--r--lib/hipe/test/maps_SUITE_data/maps_update_exact.erl32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/hipe/test/maps_SUITE_data/maps_update_exact.erl b/lib/hipe/test/maps_SUITE_data/maps_update_exact.erl
new file mode 100644
index 0000000000..6e5acb3283
--- /dev/null
+++ b/lib/hipe/test/maps_SUITE_data/maps_update_exact.erl
@@ -0,0 +1,32 @@
+-module(maps_update_exact).
+-export([test/0]).
+
+test() ->
+ M0 = id(#{1=>a,2=>b,3.0=>c,4=>d,5=>e}),
+
+ M1 = M0#{1:=42,2:=100,4:=[a,b,c]},
+ #{1:=42,2:=100,3.0:=c,4:=[a,b,c],5:=e} = M1,
+ M1 = M0#{1:=wrong,1=>42,2=>wrong,2:=100,4:=[a,b,c]},
+
+ M2 = M0#{3.0:=new},
+ #{1:=a,2:=b,3.0:=new,4:=d,5:=e} = M2,
+ M2 = M0#{3.0=>wrong,3.0:=new},
+ true = M2 =/= M0#{3=>right,3.0:=new},
+ #{ 3 := right, 3.0 := new } = M0#{3=>right,3.0:=new},
+
+ M3 = id(#{ 1 => val}),
+ #{1 := update2,1.0 := new_val4} = M3#{
+ 1.0 => new_val1, 1 := update, 1=> update3,
+ 1 := update2, 1.0 := new_val2, 1.0 => new_val3,
+ 1.0 => new_val4 },
+
+ %% Errors cases.
+ {'EXIT',{badarg,_}} = (catch ((id(nil))#{ a := b })),
+ {'EXIT',{badarg,_}} = (catch M0#{nonexisting:=val}),
+ {'EXIT',{badarg,_}} = (catch M0#{1.0:=v,1.0=>v2}),
+ {'EXIT',{badarg,_}} = (catch M0#{42.0:=v,42:=v2}),
+ {'EXIT',{badarg,_}} = (catch M0#{42=>v1,42.0:=v2,42:=v3}),
+ ok.
+
+%% Use this function to avoid compile-time evaluation of an expression.
+id(I) -> I.