Просмотр исходного кода

Backport fixes from 0.1.9

develop-0.1.8 0.1.8-1
Pedram Nimreezi 9 лет назад
Родитель
Сommit
e073d8cd6c
2 измененных файлов: 37 добавлений и 0 удалений
  1. +36
    -0
      src/glc_lib.erl
  2. +1
    -0
      src/glc_ops.erl

+ 36
- 0
src/glc_lib.erl Просмотреть файл

@ -60,6 +60,11 @@ matches({Key, '<', Term}, Event) ->
{true, Term2} -> Term2 < Term;
false -> false
end;
matches({Key, '=<', Term}, Event) ->
case gre:find(Key, Event) of
{true, Term2} -> Term2 =< Term;
false -> false
end;
matches({Key, '=', Term}, Event) ->
case gre:find(Key, Event) of
{true, Term2} -> Term2 =:= Term;
@ -75,6 +80,11 @@ matches({Key, '>', Term}, Event) ->
{true, Term2} -> Term2 > Term;
false -> false
end;
matches({Key, '>=', Term}, Event) ->
case gre:find(Key, Event) of
{true, Term2} -> Term2 >= Term;
false -> false
end;
matches({Key, '*'}, Event) ->
case gre:find(Key, Event) of
{true, _} -> true;
@ -97,10 +107,14 @@ repeat(Query, Fun) ->
-spec onoutput(glc_ops:op()) -> output | no_return().
onoutput({_, '<', _}) ->
output;
onoutput({_, '=<', _}) ->
output;
onoutput({_, '=', _}) ->
output;
onoutput({_, '>', _}) ->
output;
onoutput({_, '>=', _}) ->
output;
onoutput({_, '*'}) ->
output;
onoutput({_, '!'}) ->
@ -382,12 +396,34 @@ delete_from_any_test() ->
default_is_output_test_() ->
[?_assertEqual(output, glc_lib:onoutput(glc:lt(a, 1))),
?_assertEqual(output, glc_lib:onoutput(glc:lte(a, 1))),
?_assertEqual(output, glc_lib:onoutput(glc:eq(a, 1))),
?_assertEqual(output, glc_lib:onoutput(glc:gt(a, 1))),
?_assertEqual(output, glc_lib:onoutput(glc:gte(a, 1))),
?_assertEqual(output, glc_lib:onoutput(glc:wc(a))),
?_assertEqual(output, glc_lib:onoutput(glc:nf(a)))
].
matches_test_() ->
Event = gre:make([{a, 2}], [list]),
[?_assertEqual(true, glc_lib:matches(glc:lt(a, 3), Event)),
?_assertEqual(true, glc_lib:matches(glc:lte(a, 2), Event)),
?_assertEqual(true, glc_lib:matches(glc:eq(a, 2), Event)),
?_assertEqual(true, glc_lib:matches(glc:gt(a, 1), Event)),
?_assertEqual(true, glc_lib:matches(glc:gte(a, 2), Event)),
?_assertEqual(true, glc_lib:matches(glc:wc(a), Event)),
?_assertEqual(true, glc_lib:matches(glc:nf(b), Event)),
?_assertEqual(false, glc_lib:matches(glc:lt(a, 2), Event)),
?_assertEqual(false, glc_lib:matches(glc:lte(a, 1), Event)),
?_assertEqual(false, glc_lib:matches(glc:eq(a, 3), Event)),
?_assertEqual(false, glc_lib:matches(glc:gt(a, 2), Event)),
?_assertEqual(false, glc_lib:matches(glc:gte(a, 3), Event)),
?_assertEqual(false, glc_lib:matches(glc:wc(b), Event)),
?_assertEqual(false, glc_lib:matches(glc:nf(a), Event))
].
-ifdef(PROPER).

+ 1
- 0
src/glc_ops.erl Просмотреть файл

@ -21,6 +21,7 @@
]).
-type op() ::
{atom(), '<', term()} |
{atom(), '=<', term()} |
{atom(), '=', term()} |
{atom(), '!=', term()} |

Загрузка…
Отмена
Сохранить