diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/test/inline_SUITE.erl | 3 | ||||
-rw-r--r-- | lib/compiler/test/inline_SUITE_data/comma_splitter.erl | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/compiler/test/inline_SUITE.erl b/lib/compiler/test/inline_SUITE.erl index 086fba2649..2e17d3fde6 100644 --- a/lib/compiler/test/inline_SUITE.erl +++ b/lib/compiler/test/inline_SUITE.erl @@ -33,7 +33,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> test_lib:recompile(?MODULE), [attribute, bsdecode, bsdes, barnes2, decode1, smith, - itracer, pseudoknot, lists, really_inlined, otp_7223, + itracer, pseudoknot, comma_splitter, lists, really_inlined, otp_7223, coverage]. groups() -> @@ -78,6 +78,7 @@ attribute(Config) when is_list(Config) -> ?comp(smith). ?comp(itracer). ?comp(pseudoknot). +?comp(comma_splitter). try_inline(Mod, Config) -> ?line Src = filename:join(?config(data_dir, Config), atom_to_list(Mod)), diff --git a/lib/compiler/test/inline_SUITE_data/comma_splitter.erl b/lib/compiler/test/inline_SUITE_data/comma_splitter.erl new file mode 100644 index 0000000000..eaa89e0edc --- /dev/null +++ b/lib/compiler/test/inline_SUITE_data/comma_splitter.erl @@ -0,0 +1,18 @@ +-module(comma_splitter). +-export([?MODULE/0]). + +?MODULE() -> + {<<"def">>,<<"cba">>} = split_at_comma(<<"abc, def">>, <<>>), + ok. + +strip_leading_ws(<<N, Rest/binary>>) when N =< $\s -> + strip_leading_ws(Rest); +strip_leading_ws(B) -> + B. + +split_at_comma(<<>>, Accu) -> + {<<>>, Accu}; +split_at_comma(<<$,, Rest/binary>>, Accu) -> + {strip_leading_ws(Rest), Accu}; +split_at_comma(<<C, Rest/binary>>, Accu) -> + split_at_comma(Rest, <<C, Accu/binary>>). |