diff options
author | Björn Gustavsson <[email protected]> | 2016-05-25 07:06:55 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-05-30 13:19:20 +0200 |
commit | 88632d70cc866b5e54589ccb9311c7c5a88ecb46 (patch) | |
tree | 286c932ee10b8e0b52691958fcad3390c8ab6090 /lib/compiler/test | |
parent | 4992284e993f26afc83630dd6c1ffeb27a00ef65 (diff) | |
download | otp-88632d70cc866b5e54589ccb9311c7c5a88ecb46.tar.gz otp-88632d70cc866b5e54589ccb9311c7c5a88ecb46.tar.bz2 otp-88632d70cc866b5e54589ccb9311c7c5a88ecb46.zip |
beam_validator: Add is_bitstring/1 as a safe BIF
beam_validator wrongly complained that the following was
not safe because it didn't know that is_bitstring/1 is safe:
food(Curriculum) ->
[try
is_bitstring(functions)
catch _ ->
0
end, Curriculum].
While we are it, also add a new bif_SUITE test suite to cover some
more code in beam_validator.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/Makefile | 2 | ||||
-rw-r--r-- | lib/compiler/test/bif_SUITE.erl | 65 |
2 files changed, 67 insertions, 0 deletions
diff --git a/lib/compiler/test/Makefile b/lib/compiler/test/Makefile index da4ea548fd..f0185acbc7 100644 --- a/lib/compiler/test/Makefile +++ b/lib/compiler/test/Makefile @@ -17,6 +17,7 @@ MODULES= \ beam_reorder_SUITE \ beam_type_SUITE \ beam_utils_SUITE \ + bif_SUITE \ bs_bincomp_SUITE \ bs_bit_binaries_SUITE \ bs_construct_SUITE \ @@ -54,6 +55,7 @@ NO_OPT= \ beam_reorder \ beam_type \ beam_utils \ + bif \ bs_construct \ bs_match \ bs_utf \ diff --git a/lib/compiler/test/bif_SUITE.erl b/lib/compiler/test/bif_SUITE.erl new file mode 100644 index 0000000000..51bc71da81 --- /dev/null +++ b/lib/compiler/test/bif_SUITE.erl @@ -0,0 +1,65 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2016. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% +-module(bif_SUITE). + +-export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1, + init_per_group/2,end_per_group/2, + beam_validator/1]). + +suite() -> + [{ct_hooks,[ts_install_cth]}]. + +all() -> + test_lib:recompile(?MODULE), + [{group,p}]. + +groups() -> + [{p,[parallel], + [beam_validator + ]}]. + +init_per_suite(Config) -> + Config. + +end_per_suite(_Config) -> + ok. + +init_per_group(_GroupName, Config) -> + Config. + +end_per_group(_GroupName, Config) -> + Config. + +%% Cover code in beam_validator. + +beam_validator(Config) -> + [false,Config] = food(Config), + + true = is_number(42.0), + false = is_port(Config), + + ok. + +food(Curriculum) -> + [try + is_bitstring(functions) + catch _ -> + 0 + end, Curriculum]. |