aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/basic_SUITE_data/basic_switches.erl
blob: 0a7ae5b8b7bf979d2b73cf6d817e21147978a8ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
%%% -*- erlang-indent-level: 2 -*-
%%%-------------------------------------------------------------------
%%% Author: Kostis Sagonas
%%%
%%% Contains tests for pattern matching switches.
%%%-------------------------------------------------------------------
-module(basic_switches).

-export([test/0]).

test() ->
  ok = test_switch_mix(),
  ok.

%%---------------------------------------------------------------------

-define(BIG1, 21323233222132323322).
-define(BIG2, 4242424242424242424242424242424242).

test_switch_mix() ->
  small1 = t(42),
  small2 = t(17),
  big1 = t(?BIG1),
  big2 = t(?BIG2),
  atom = t(foo),
  pid = t(self()),
  float = t(4.2),
  ok.

t(V) ->
  S = self(),
  case V of
    42 -> small1;
    17 -> small2;
    ?BIG1 -> big1;
    ?BIG2 -> big2;
    1 -> no;
    2 -> no;
    3 -> no;
    4 -> no;
    5 -> no;
    6 -> no;
    7 -> no;
    8 -> no;
    foo -> atom;
    9 -> no;
    4.2 -> float;
    S -> pid;
    _ -> no
  end.

%%---------------------------------------------------------------------