aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/erl_internal.erl4
-rw-r--r--lib/stdlib/test/binary_module_SUITE.erl12
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/stdlib/src/erl_internal.erl b/lib/stdlib/src/erl_internal.erl
index 16173d8210..41a42f7907 100644
--- a/lib/stdlib/src/erl_internal.erl
+++ b/lib/stdlib/src/erl_internal.erl
@@ -87,6 +87,8 @@ guard_bif(is_reference, 1) -> true;
guard_bif(is_tuple, 1) -> true;
guard_bif(is_record, 2) -> true;
guard_bif(is_record, 3) -> true;
+guard_bif(binary_part, 2) -> true;
+guard_bif(binary_part, 3) -> true;
guard_bif(Name, A) when is_atom(Name), is_integer(A) -> false.
%% Erlang type tests.
@@ -229,6 +231,8 @@ bif(apply, 2) -> true;
bif(apply, 3) -> true;
bif(atom_to_binary, 2) -> true;
bif(atom_to_list, 1) -> true;
+bif(binary_part, 2) -> true;
+bif(binary_part, 3) -> true;
bif(binary_to_atom, 2) -> true;
bif(binary_to_existing_atom, 2) -> true;
bif(binary_to_list, 1) -> true;
diff --git a/lib/stdlib/test/binary_module_SUITE.erl b/lib/stdlib/test/binary_module_SUITE.erl
index c51c70cfa8..4ba3ef4809 100644
--- a/lib/stdlib/test/binary_module_SUITE.erl
+++ b/lib/stdlib/test/binary_module_SUITE.erl
@@ -2,7 +2,7 @@
-export([all/1, interesting/1,random_ref_comp/1,random_ref_sr_comp/1,
random_ref_fla_comp/1,parts/1, bin_to_list/1, list_to_bin/1,
- copy/1, referenced/1,encode_decode/1]).
+ copy/1, referenced/1,guard/1,encode_decode/1]).
-export([random_number/1, make_unaligned/1]).
@@ -32,7 +32,7 @@ run() ->
all(suite) -> [interesting,random_ref_fla_comp,random_ref_sr_comp,
random_ref_comp,parts,bin_to_list, list_to_bin, copy,
- referenced,encode_decode].
+ referenced,guard,encode_decode].
-define(MASK_ERROR(EXPR),mask_error((catch (EXPR)))).
@@ -314,7 +314,6 @@ do_interesting(Module) ->
?line <<0>> = ?MASK_ERROR(Module:encode_unsigned(0,big)),
ok.
-
encode_decode(doc) ->
["test binary:encode_unsigned/1,2 and binary:decode_unsigned/1,2"];
encode_decode(Config) when is_list(Config) ->
@@ -361,6 +360,11 @@ encode_decode_loop(Range, X) ->
exit(mismatch)
end.
+guard(doc) ->
+ ["Smoke test of the guard BIFs binary_part/2,3"];
+guard(Config) when is_list(Config) ->
+ {comment, "Guard tests are run in emulator test suite"}.
+
referenced(doc) ->
["Test refernced_byte_size/1 bif."];
referenced(Config) when is_list(Config) ->
@@ -548,6 +552,8 @@ random_parts(N) ->
true = ?MASK_ERROR(binary:part(Str,Z)) =:=
?MASK_ERROR(binref:part(Str,Z)),
true = ?MASK_ERROR(binary:part(Str,Z)) =:=
+ ?MASK_ERROR(erlang:binary_part(Str,Z)),
+ true = ?MASK_ERROR(binary:part(Str,Z)) =:=
?MASK_ERROR(binary:part(make_unaligned(Str),Z))
end || Z <- Parts1 ],
random_parts(N-1).