You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2019/02/22 17:28:29 UTC
[couchdb-khash] 22/25: Change minimum supported Erlang version to
OTP 19
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-khash.git
commit f24d44b7870fc8192bb32a6be42f567ddc6c37e9
Author: Jay Doane <ja...@apache.org>
AuthorDate: Thu Feb 21 16:05:38 2019 -0800
Change minimum supported Erlang version to OTP 19
Eliminate test/khash_rand.erl in favor of direct rand:uniform calls
---
.travis.yml | 7 ++++---
rebar.config | 10 ----------
test/gen_term.erl | 28 +++++++++++++-------------
test/khash_rand.erl | 57 -----------------------------------------------------
test/khash_test.erl | 4 ++--
5 files changed, 20 insertions(+), 86 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 3a637c2..ad5b569 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,9 @@
language: erlang
otp_release:
+ - 21.2
+ - 20.3
- 19.3
- - 18.3
- - 17.5
- - R16B03-1
+script:
+ - make check
diff --git a/rebar.config b/rebar.config
index bb9a1e5..6d77caa 100644
--- a/rebar.config
+++ b/rebar.config
@@ -10,13 +10,3 @@
{"(linux|solaris|darwin|freebsd)", "CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3"},
{"win32", "CFLAGS", "$CFLAGS /O2 /DNDEBUG /Wall"}
]}.
-
-{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/gen_term.erl b/test/gen_term.erl
index 2937113..08d9f35 100644
--- a/test/gen_term.erl
+++ b/test/gen_term.erl
@@ -42,18 +42,18 @@ gen_atom(MaxSize) ->
gen_integer(_) ->
- Value = case khash_rand:uniform() < 0.5 of
- true -> khash_rand:uniform(127);
- false -> khash_rand:uniform(16#FFFFFFFF)
+ Value = case rand:uniform() < 0.5 of
+ true -> rand:uniform(127);
+ false -> rand:uniform(16#FFFFFFFF)
end,
- case khash_rand:uniform() < 0.5 of
+ case rand:uniform() < 0.5 of
true -> -1 * Value;
false -> Value
end.
gen_float(_) ->
- khash_rand:uniform() * float(16#FFFFFFFF).
+ rand:uniform() * float(16#FFFFFFFF).
gen_reference(_) ->
@@ -62,12 +62,12 @@ gen_reference(_) ->
gen_port(_) ->
Ports = erlang:ports(),
- lists:nth(khash_rand:uniform(length(Ports)), Ports).
+ lists:nth(rand:uniform(length(Ports)), Ports).
gen_pid(_) ->
Pids = erlang:processes(),
- lists:nth(khash_rand:uniform(length(Pids)), Pids).
+ lists:nth(rand:uniform(length(Pids)), Pids).
gen_tuple(MaxSize) ->
@@ -75,18 +75,18 @@ gen_tuple(MaxSize) ->
gen_list(MaxSize) ->
- Width = khash_rand:uniform(MaxSize),
+ Width = rand:uniform(MaxSize),
[any(MaxSize-Width) || _ <- lists:seq(1, Width)].
gen_short_string(_) ->
- Size = khash_rand:uniform(255),
- [khash_rand:uniform(127) || _ <- lists:seq(1, Size)].
+ Size = rand:uniform(255),
+ [rand:uniform(127) || _ <- lists:seq(1, Size)].
gen_string(_) ->
- Size = khash_rand:uniform(4096),
- [khash_rand:uniform(127) || _ <- lists:seq(1, Size)].
+ Size = rand:uniform(4096),
+ [rand:uniform(127) || _ <- lists:seq(1, Size)].
gen_binary(MaxSize) ->
@@ -99,7 +99,7 @@ gen_bitstring(MaxSize) ->
gen_bignum(_) ->
- 16#FFFFFFFFFFFFFFFF + khash_rand:uniform(16#FFFFFFFF).
+ 16#FFFFFFFFFFFFFFFF + rand:uniform(16#FFFFFFFF).
gen_function(_) ->
@@ -107,7 +107,7 @@ gen_function(_) ->
choice(Options) ->
- lists:nth(khash_rand:uniform(length(Options)), Options).
+ lists:nth(rand:uniform(length(Options)), Options).
value_types() ->
diff --git a/test/khash_rand.erl b/test/khash_rand.erl
deleted file mode 100644
index 76b7e38..0000000
--- a/test/khash_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(khash_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/khash_test.erl b/test/khash_test.erl
index 1f116d3..cbfa62f 100644
--- a/test/khash_test.erl
+++ b/test/khash_test.erl
@@ -366,7 +366,7 @@ run_to_list({D, H}) ->
weighted_choice(Items0) ->
Items = lists:sort(Items0),
Sum = lists:sum([W || {W, _} <- Items]),
- Choice = khash_rand:uniform() * Sum,
+ Choice = rand:uniform() * Sum,
weighted_choice(Items, 0.0, Choice).
weighted_choice([], _, _) ->
@@ -378,7 +378,7 @@ weighted_choice([{_, I} | _], _, _) ->
random_key(D) ->
Keys = lists:usort(dict:fetch_keys(D) ++ [foo]),
- lists:nth(khash_rand:uniform(length(Keys)), Keys).
+ lists:nth(rand:uniform(length(Keys)), Keys).
random_val() ->
gen_term:any().