aboutsummaryrefslogtreecommitdiffstats
path: root/lib/debugger/test/int_SUITE_data/guards.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-09-09 10:50:42 +0200
committerBjörn Gustavsson <[email protected]>2010-09-09 10:50:42 +0200
commit476cdebba29d1e60389cee2c908ba65b45bf7b77 (patch)
treefbd7879469604f66e40325c1d2029ee9d6ec9e7b /lib/debugger/test/int_SUITE_data/guards.erl
parent3608de28c0bb6367182d781797032ee05b516b21 (diff)
parent27a5daae33616e662a36ed514c31618d51ad66e3 (diff)
downloadotp-476cdebba29d1e60389cee2c908ba65b45bf7b77.tar.gz
otp-476cdebba29d1e60389cee2c908ba65b45bf7b77.tar.bz2
otp-476cdebba29d1e60389cee2c908ba65b45bf7b77.zip
Merge branch 'maint-r13' into dev
* maint-r13: Add test suite for ic Add test suite for runtime_tools Add test suite for debugger Add test suite for os_mon
Diffstat (limited to 'lib/debugger/test/int_SUITE_data/guards.erl')
-rw-r--r--lib/debugger/test/int_SUITE_data/guards.erl108
1 files changed, 108 insertions, 0 deletions
diff --git a/lib/debugger/test/int_SUITE_data/guards.erl b/lib/debugger/test/int_SUITE_data/guards.erl
new file mode 100644
index 0000000000..c847bb6a8c
--- /dev/null
+++ b/lib/debugger/test/int_SUITE_data/guards.erl
@@ -0,0 +1,108 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%
+-module(guards).
+
+-export([guards/0]).
+
+guards() ->
+ ok = t(),
+ ok = f(),
+ ok = ct(1),
+ ok = multi(1),
+ ok = multi(2),
+ ok = multi(3).
+
+%% The following tests are always true.
+t() when integer(42) ->
+ ok;
+t() when float(2.0) ->
+ ok;
+t() when number(7) ->
+ ok;
+t() when number(3.14) ->
+ ok;
+t() when atom(error) ->
+ ok;
+t() when list([a]) ->
+ ok;
+t() when tuple({}) ->
+ ok;
+t() when tuple({1, 2}) ->
+ ok.
+
+%% The following tests are always false.
+f() when integer(a) ->
+ ok;
+f() when float(b) ->
+ ok;
+f() when number(c) ->
+ ok;
+f() when atom(42) ->
+ ok;
+f() when list(33) ->
+ ok;
+f() when list({}) ->
+ ok;
+f() when list({1, 2}) ->
+ ok;
+f() when tuple(33) ->
+ ok;
+f() when tuple([a]) ->
+ ok;
+f() when tuple([]) ->
+ ok;
+f() when tuple(35) ->
+ ok;
+f() ->
+ ok.
+
+%% The following tests are always true.
+ct(X) ->
+ case X of
+ Y when integer(42) ->
+ ok;
+ Y when float(2.0) ->
+ ok;
+ Y when number(7) ->
+ ok;
+ Y when number(3.14) ->
+ ok;
+ Y when atom(error) ->
+ ok;
+ Y when list([a]) ->
+ ok;
+ Y when tuple({}) ->
+ ok;
+ Y when tuple({1, 2}) ->
+ ok
+ end.
+
+multi(X) ->
+ case X of
+ Y when float(Y) ; integer(Y) ->
+ ok;
+ Y when Y > 1, Y < 10 ; atom(Y) ->
+ ok;
+ Y when Y == 4, number(Y) ; list(Y) ->
+ pannkaka;
+ Y when Y==3 ; Y==5 ; Y==6 ->
+ ok
+ end.