aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-05-19 15:04:21 +0200
committerBjörn Gustavsson <[email protected]>2016-05-23 08:39:53 +0200
commit09d729daa2350fc4de577467dca4a8e65f30979b (patch)
treeec953a56fa9d95cbed4196fe320539e3f58dfe0b /lib
parent57c4432ed543898676ccc646ab6d556c7e6ea79a (diff)
downloadotp-09d729daa2350fc4de577467dca4a8e65f30979b.tar.gz
otp-09d729daa2350fc4de577467dca4a8e65f30979b.tar.bz2
otp-09d729daa2350fc4de577467dca4a8e65f30979b.zip
beam_utils_SUITE: Cover more lines in beam_utils
By first adding a call to error/1 to each uncovered line, QuickCheck could find test cases that would cover the lines.
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/test/beam_utils_SUITE.erl47
1 files changed, 45 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_utils_SUITE.erl b/lib/compiler/test/beam_utils_SUITE.erl
index 6353ed3242..ae813d563b 100644
--- a/lib/compiler/test/beam_utils_SUITE.erl
+++ b/lib/compiler/test/beam_utils_SUITE.erl
@@ -23,7 +23,7 @@
init_per_group/2,end_per_group/2,
apply_fun/1,apply_mf/1,bs_init/1,bs_save/1,
is_not_killed/1,is_not_used_at/1,
- select/1,y_catch/1,otp_8949_b/1,liveopt/1]).
+ select/1,y_catch/1,otp_8949_b/1,liveopt/1,coverage/1]).
-export([id/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
@@ -43,7 +43,8 @@ groups() ->
select,
y_catch,
otp_8949_b,
- liveopt
+ liveopt,
+ coverage
]}].
init_per_suite(Config) ->
@@ -268,6 +269,48 @@ liveopt_fun(Peer, Cause, Origin) ->
void
end.
+%% Thanks to QuickCheck.
+coverage(_Config) ->
+ 42+7 = merchant([[],7,false]),
+
+ {'EXIT',{{try_clause,0},_}} = (catch resulting([0], stone)),
+ 0.0 = resulting([true], stone),
+
+ {'EXIT',{if_clause,_}} = (catch clinic(false)),
+ {'EXIT',{{try_clause,"trials"},_}} = (catch clinic(true)),
+
+ {'EXIT',{function_clause,_}} = (catch town(overall, {{abc},alcohol})),
+
+ ok.
+
+%% Cover check_liveness/3.
+merchant([Merchant, Laws, Electric]) ->
+ id(42),
+ oklahoma([[] || 0 <- Merchant],
+ if true; Electric -> Laws end) + 42.
+oklahoma([], Int) -> Int.
+
+town(overall, {{If}, Healing = alcohol})
+ when Healing#{[] => Healing}; include ->
+ [If || Healing <- awareness].
+
+%% Cover is_reg_used_at/3.
+resulting([Conservation], stone) ->
+ try 0 of
+ Conservation when Conservation -> Conservation;
+ _ when Conservation; 0 -> 0.0
+ after
+ Conservation
+ end.
+
+%% Cover is_reg_used_at_1/3.
+clinic(Damage) ->
+ if
+ Damage ->
+ try "trials" of Damage when Damage -> Damage catch true -> [] end
+ end,
+ carefully.
+
%% The identity function.
id(I) -> I.