~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/dialyzer/test/opaque_tests_SUITE_data/src/queue/queue_use.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-module(queue_use).
 
2
 
 
3
-export([ok1/0, ok2/0]).
 
4
-export([wrong1/0, wrong2/0, wrong3/0, wrong4/0, wrong5/0, wrong6/0, wrong7/0, wrong8/0]).
 
5
 
 
6
ok1() ->
 
7
    queue:is_empty(queue:new()).
 
8
 
 
9
ok2() ->
 
10
    Q0 = queue:new(),
 
11
    Q1 = queue:in(42, Q0),
 
12
    {{value, 42}, Q2} = queue:out(Q1),
 
13
    queue:is_empty(Q2).
 
14
 
 
15
%%--------------------------------------------------
 
16
 
 
17
wrong1() ->
 
18
    queue:is_empty({[],[]}).
 
19
 
 
20
wrong2() ->
 
21
    Q0 = {[],[]},
 
22
    queue:in(42, Q0).
 
23
 
 
24
wrong3() ->
 
25
    Q0 = queue:new(),
 
26
    Q1 = queue:in(42, Q0),
 
27
    {[42],Q2} = Q1,
 
28
    Q2.
 
29
 
 
30
wrong4() ->
 
31
    Q0 = queue:new(),
 
32
    Q1 = queue:in(42, Q0),
 
33
    Q1 =:= {[42],[]}.
 
34
 
 
35
wrong5() ->
 
36
    {F, _R} = queue:new(),
 
37
    F.
 
38
 
 
39
wrong6() ->
 
40
    {{value, 42}, Q2} = queue:out({[42],[]}),
 
41
    Q2.
 
42
 
 
43
%%--------------------------------------------------
 
44
 
 
45
-record(db, {p, q}).
 
46
 
 
47
wrong7() ->
 
48
    add_unique(42, #db{p = [], q = queue:new()}).
 
49
 
 
50
add_unique(E, DB) ->
 
51
    case is_in_queue(E, DB) of
 
52
        true -> DB;
 
53
        false -> DB#db{q = queue:in(E, DB#db.q)}
 
54
    end.
 
55
 
 
56
is_in_queue(P, #db{q = {L1,L2}}) ->
 
57
    lists:member(P, L1) orelse lists:member(P, L2).
 
58
 
 
59
%%--------------------------------------------------
 
60
 
 
61
wrong8() ->
 
62
    tuple_queue({42, gazonk}).
 
63
 
 
64
tuple_queue({F, Q}) ->
 
65
    queue:in(F, Q).
 
66