diff options
author | Björn Gustavsson <[email protected]> | 2018-11-25 08:11:52 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-11-28 11:36:54 +0100 |
commit | 96ac99d3e9b12295b7e8a70888fd1134a78e63a8 (patch) | |
tree | 9265a1416c674c5b50a96733f1c3e04f79e7ac8b /lib/compiler/test | |
parent | 2e59e2ab69d7f50c8a03b1c89528f8cf38a3a8b4 (diff) | |
download | otp-96ac99d3e9b12295b7e8a70888fd1134a78e63a8.tar.gz otp-96ac99d3e9b12295b7e8a70888fd1134a78e63a8.tar.bz2 otp-96ac99d3e9b12295b7e8a70888fd1134a78e63a8.zip |
Cover more code in beam_jump
The previous optimizations caused some code in beam_jump to
become uncovered. Add tests to cover more code. Also remove
a clause in beam_jump:opt/3 that does not seem possible to
cover anymore (this is safe, because the clause was an
optimization).
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/beam_jump_SUITE.erl | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_jump_SUITE.erl b/lib/compiler/test/beam_jump_SUITE.erl index 40eb6f06c3..759d884dc4 100644 --- a/lib/compiler/test/beam_jump_SUITE.erl +++ b/lib/compiler/test/beam_jump_SUITE.erl @@ -22,7 +22,8 @@ -export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1, init_per_group/2,end_per_group/2, undefined_label/1,ambiguous_catch_try_state/1, - unsafe_move_elimination/1,build_tuple/1]). + unsafe_move_elimination/1,build_tuple/1, + coverage/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -35,7 +36,8 @@ groups() -> [undefined_label, ambiguous_catch_try_state, unsafe_move_elimination, - build_tuple + build_tuple, + coverage ]}]. init_per_suite(Config) -> @@ -126,6 +128,44 @@ do_build_tuple(Message) -> {Message#message3.id, Res} end. +coverage(_Config) -> + ok = coverage_1(ok), + {error,badarg} = coverage_1({error,badarg}), + + gt = coverage_2(100, 42), + le = coverage_2(100, 999), + le = coverage_2([], []), + gt = coverage_2([], xxx), + + ok. + +coverage_1(Var) -> + case id(Var) of + ok -> ok; + Error -> Error + end. + +%% Cover beam_jump:invert_test(is_ne_exact). +coverage_2(Pre1, Pre2) -> + case + case Pre1 == [] of + false -> + false; + true -> + Pre2 /= [] + end + of + true -> + gt; + false -> + case Pre1 > Pre2 of + true -> + gt; + false -> + le + end + end. + id(I) -> I. |