Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement queue emptying.

  • Loading branch information...
commit 7a8267845f734fbee8a019db7a19a81b70343d49 1 parent 33a5fee
@jlouis authored
Showing with 10 additions and 5 deletions.
  1. +6 −5 test/jobs_eqc_queue.erl
  2. +4 −0 test/jobs_queue_model.erl
View
11 test/jobs_eqc_queue.erl
@@ -29,11 +29,12 @@ g_queue(N) ->
{N,
?LET(Q, g_queue(max(0, N-2)),
frequency(
- [{2, oneof(
- [{call, jobs_queue, in, [0,
- g_job(), Q]}])},
- {1, oneof(
- [{call, ?MODULE, out, [nat(), Q]}])}]))}]).
+ [
+ {200, {call, jobs_queue, in, [0, g_job(), Q]}},
+ {100, {call, ?MODULE, out, [nat(), Q]}},
+ {1, {call, jobs_queue, empty, [Q]}}
+ ]))}
+ ]).
out(N, Q) ->
element(2, jobs_queue:out(N, Q)).
View
4 test/jobs_queue_model.erl
@@ -52,6 +52,10 @@ out(K, Q, Acc) when K > 0 ->
out(0, NQ, Acc)
end.
+empty(#queue {} = Q) ->
+ Q#queue { st = queue:new(),
+ oldest_job = undefined }.
+
representation(#queue { st = Q, oldest_job = OJ} ) ->
Cts = queue:to_list(Q),
[{oldest_job, OJ},
Please sign in to comment.
Something went wrong with that request. Please try again.