aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl
diff options
context:
space:
mode:
authorErik Norgren <[email protected]>2014-06-09 14:12:08 +0200
committerMagnus Lång <[email protected]>2016-05-23 18:03:09 +0200
commitf833a900897faae48230bc8c1e7572fb470a4a6f (patch)
tree582c8c3d2fdf6e8db36d0b61c98f18a59768495d /lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl
parentb9068c94921e97cc918e9c8664c252af33bfaf39 (diff)
downloadotp-f833a900897faae48230bc8c1e7572fb470a4a6f.tar.gz
otp-f833a900897faae48230bc8c1e7572fb470a4a6f.tar.bz2
otp-f833a900897faae48230bc8c1e7572fb470a4a6f.zip
hipe: Add test suite for verifying optimisations
* Added a suite opt_verify_SUITE.erl to HiPE that tests for the results of optimisations, with a single testcase that checks that the icode_call_elim optimisation pass does remove calls to maps:is_key/2 where sound and not otherwise. * Made hipe_testsuite_driver only create explicitly listed suites.
Diffstat (limited to 'lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl')
-rw-r--r--lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl b/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl
new file mode 100644
index 0000000000..c8ddfa1e75
--- /dev/null
+++ b/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl
@@ -0,0 +1,32 @@
+-module(call_elim_test_branches_opt_poss).
+
+-export([test/1]).
+
+test(A) ->
+ if A > 0 ->
+ true = has_a_field(#{a=>true}),
+ true = has_a_field(#{b=>1, a=>"2"}),
+ true = has_a_field(#{a=>5, c=>4}),
+ true = has_tuple_field(#{{ab, 1}=><<"qq">>, 1 =>0}),
+ true = has_tuple_field(#{up =>down, {ab, 1}=>[]}),
+ true = has_tuple_field(#{{ab, 1}=>42});
+ A =< 0 ->
+ true = has_a_field(#{a=>q, 'A' =>nej}),
+ true = has_a_field(#{a=>"hej", false=>true}),
+ true = has_a_field(#{a=>3}),
+ true = has_tuple_field(#{{ab, 1}=>q, 'A' =>nej}),
+ true = has_tuple_field(#{{ab, 1}=>"hej", false=>true}),
+ true = has_tuple_field(#{{ab, 1}=>3})
+ end,
+ true = has_nil_field(#{[] =>3, b =>"seven"}),
+ true = has_nil_field(#{"seventeen"=>17, []=>nil}),
+ ok.
+
+has_tuple_field(#{{ab, 1}:=_}) -> true;
+has_tuple_field(#{}) -> false.
+
+has_a_field(#{a:=_}) -> true;
+has_a_field(#{}) -> false.
+
+has_nil_field(#{[]:=_}) -> true;
+has_nil_field(#{}) -> false.