This is an automated email from the ASF dual-hosted git repository. jaydoane pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb-b64url.git
commit a48ee011c2212b82efab4ff15c55ca6ba58476da Author: Jay Doane <jaydo...@apache.org> AuthorDate: Fri Feb 22 09:40:15 2019 -0800 Change minimum supported Erlang version to OTP 19 Eliminate test/b64url_rand.erl in favor of direct rand:uniform calls --- .travis.yml | 11 +++++----- rebar.config | 11 ---------- test/b64url_rand.erl | 57 -------------------------------------------------- test/b64url_tests.erl | 12 +++++------ test/benchmark.escript | 4 ++-- 5 files changed, 14 insertions(+), 81 deletions(-) diff --git a/.travis.yml b/.travis.yml index e9367c6..54b91fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,9 @@ language: erlang otp_release: - - 18.2 - - 18.1 - - 18.0 - - 17.5 - - R16B03-1 + - 21.2 + - 20.3 + - 19.3 + +script: + - make check diff --git a/rebar.config b/rebar.config index a84ea97..ba1d456 100644 --- a/rebar.config +++ b/rebar.config @@ -13,14 +13,3 @@ ]}. {eunit_opts, [verbose]}. - -{erl_opts, [ - {platform_define, "^R16", 'NORANDMODULE'}, - {platform_define, "^17", 'NORANDMODULE'} -]}. - -{eunit_compile_opts, [ - {platform_define, "^R16", 'NORANDMODULE'}, - {platform_define, "^17", 'NORANDMODULE'} -]}. - diff --git a/test/b64url_rand.erl b/test/b64url_rand.erl deleted file mode 100644 index a397c3b..0000000 --- a/test/b64url_rand.erl +++ /dev/null @@ -1,57 +0,0 @@ -% 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. - --module(b64url_rand). - - --export([ - uniform/0, - uniform/1 -]). - - --ifdef(NORANDMODULE). - - -uniform() -> - maybe_set_random_seed(), - random:uniform(). - - -uniform(N) -> - maybe_set_random_seed(), - random:uniform(N). - - -maybe_set_random_seed() -> - case get(random_seed) of - undefined -> - {_, Sec, USec} = os:timestamp(), - Seed = {erlang:phash2(self()), Sec, USec}, - random:seed(Seed); - _ -> - ok - end. - - --else. - - -uniform() -> - rand:uniform(). - - -uniform(N) -> - rand:uniform(N). - - --endif. diff --git a/test/b64url_tests.erl b/test/b64url_tests.erl index c5831ef..27e69db 100644 --- a/test/b64url_tests.erl +++ b/test/b64url_tests.erl @@ -65,7 +65,7 @@ decode_bad_length_test() -> gen_binary() -> % -1 to allow for 0 length - Length = b64url_rand:uniform(?MAX_SIZE) - 1, + Length = rand:uniform(?MAX_SIZE) - 1, crypto:strong_rand_bytes(Length). @@ -86,14 +86,14 @@ bad_len_binary() -> to_iolist(<<>>) -> - case b64url_rand:uniform(2) of + case rand:uniform(2) of 1 -> <<>>; 2 -> [<<>>] end; to_iolist(B) when is_binary(B), size(B) > 0 -> - S = b64url_rand:uniform(size(B)), + S = rand:uniform(size(B)), <<First:S/binary, Second/binary>> = B, - case b64url_rand:uniform(3) of + case rand:uniform(3) of 1 -> [to_iolist(First), Second]; 2 -> @@ -104,13 +104,13 @@ to_iolist(B) when is_binary(B), size(B) > 0 -> insert_error(B) when is_binary(B), size(B) < 2 -> - case b64url_rand:uniform(2) of + case rand:uniform(2) of 1 -> {<<122, 255>>, 0}; 2 -> {<<122, 122, 255>>, 0} end; insert_error(B) when is_binary(B) -> B64 = couch_encode_base64url(B), - S = b64url_rand:uniform(size(B64) - 1), + S = rand:uniform(size(B64) - 1), <<First:S/binary, _:1/binary, Second/binary>> = B64, {<<First:S/binary, 255, Second/binary>>, 4 * (S div 4)}. diff --git a/test/benchmark.escript b/test/benchmark.escript index 75c2341..00a6f0d 100755 --- a/test/benchmark.escript +++ b/test/benchmark.escript @@ -115,7 +115,7 @@ run_worker(St, Started) -> do_round_trip(St) -> - Size = St#st.minsize + b64url_rand:uniform(St#st.maxsize - St#st.minsize), + Size = St#st.minsize + rand:uniform(St#st.maxsize - St#st.minsize), Data = crypto:strong_rand_bytes(Size), Encoded = (St#st.module):encode(Data), Data = (St#st.module):decode(Encoded), @@ -137,7 +137,7 @@ decode(Url64) -> base64:decode(<<Url2/binary, Padding/binary>>). randomize(List) -> - List0 = [{b64url_rand:uniform(), L} || L <- List], + List0 = [{rand:uniform(), L} || L <- List], List1 = lists:sort(List0), [L || {_, L} <- List1].