Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 8cdce4b

Browse files
committed
Merge pull request #11 from knutin/master
Pull in hyper:is_hyper/1 from Knut
2 parents 703cf11 + 8f6dc5a commit 8cdce4b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ estimates.csv
77
erl_crash.dump
88
*.so
99
*.o
10+
*.d
11+
.rebar

src/hyper.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-export([new/1, new/2, insert/2, insert_many/2]).
99
-export([union/1, union/2]).
1010
-export([card/1, intersect_card/2]).
11-
-export([to_json/1, from_json/1, from_json/2, precision/1, bytes/1]).
11+
-export([to_json/1, from_json/1, from_json/2, precision/1, bytes/1, is_hyper/1]).
1212
-export([compact/1, reduce_precision/2]).
1313

1414
-type precision() :: 4..16.
@@ -39,6 +39,10 @@ new(P) ->
3939
new(P, Mod) when 4 =< P andalso P =< 16 andalso is_atom(Mod) ->
4040
#hyper{p = P, registers = {Mod, Mod:new(P)}}.
4141

42+
-spec is_hyper(filter()) -> boolean().
43+
is_hyper(#hyper{}) -> true;
44+
is_hyper(_) -> false.
45+
4246

4347
-spec insert(value(), filter()) -> filter().
4448
insert(Value, #hyper{registers = {Mod, Registers}, p = P} = Hyper)

test/hyper_test.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ hyper_test_() ->
1717

1818
{foreach, fun () -> ok end, fun (_) -> ok end,
1919
[
20+
?_test(is_hyper_t()),
2021
?_test(basic_t()),
2122
?_test(serialization_t()),
2223
?_test(reduce_precision_t()),
@@ -39,6 +40,10 @@ hyper_test_() ->
3940
RunProp(prop_serialize())
4041
]}.
4142

43+
is_hyper_t() ->
44+
?assert(hyper:is_hyper(hyper:new(4, hyper_binary))),
45+
?assertNot(hyper:is_hyper(foo)).
46+
4247
basic_t() ->
4348
[?assertEqual(1, trunc(
4449
hyper:card(

0 commit comments

Comments
 (0)