diff options
author | Björn Gustavsson <[email protected]> | 2016-06-29 06:08:29 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-09-21 14:07:53 +0200 |
commit | 97820c026969de7e98d948b301da1e6956f0504d (patch) | |
tree | 5795c14f316cfddc7364a1b7e3214aa324f1e15d /lib | |
parent | 300698da10e777c2a466dd02accf6179dd79e130 (diff) | |
download | otp-97820c026969de7e98d948b301da1e6956f0504d.tar.gz otp-97820c026969de7e98d948b301da1e6956f0504d.tar.bz2 otp-97820c026969de7e98d948b301da1e6956f0504d.zip |
bs_match_SUITE: Add a test case for beam_utils
During development, a bug in beam_utils caused a compiler failure
in xmerl. If the bug reappears, make sure that we catch it when
compiling the compiler test suite.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/test/bs_match_SUITE.erl | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl index 224abf6c29..f8af070c44 100644 --- a/lib/compiler/test/bs_match_SUITE.erl +++ b/lib/compiler/test/bs_match_SUITE.erl @@ -38,7 +38,8 @@ no_partition/1,calling_a_binary/1,binary_in_map/1, match_string_opt/1,select_on_integer/1, map_and_binary/1,unsafe_branch_caching/1, - bad_literals/1,good_literals/1,constant_propagation/1]). + bad_literals/1,good_literals/1,constant_propagation/1, + parse_xml/1]). -export([coverage_id/1,coverage_external_ignore/2]). @@ -69,7 +70,7 @@ groups() -> no_partition,calling_a_binary,binary_in_map, match_string_opt,select_on_integer, map_and_binary,unsafe_branch_caching, - bad_literals,good_literals,constant_propagation]}]. + bad_literals,good_literals,constant_propagation,parse_xml]}]. init_per_suite(Config) -> @@ -1451,6 +1452,26 @@ constant_propagation_c() -> X end. +parse_xml(_Config) -> + <<"<?xmlX">> = do_parse_xml(<<"<?xmlX">>), + <<" ">> = do_parse_xml(<<"<?xml ">>), + ok. + +do_parse_xml(<<"<?xml"/utf8,Rest/binary>> = Bytes) -> + %% Delayed sub-binary creation is not safe. A buggy (development) + %% version of check_liveness_everywhere() in beam_utils would turn + %% on the optimization. + Rest1 = case is_next_char_whitespace(Rest) of + false -> + Bytes; + true -> + id(Rest) + end, + id(Rest1). + +is_next_char_whitespace(<<C/utf8,_/binary>>) -> + C =:= $\s. + check(F, R) -> R = F(). |