From f833a900897faae48230bc8c1e7572fb470a4a6f Mon Sep 17 00:00:00 2001 From: Erik Norgren Date: Mon, 9 Jun 2014 14:12:08 +0200 Subject: 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. --- .../call_elim_test_branches_opt_poss.erl | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl (limited to 'lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl') 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. -- cgit v1.2.3