aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/basic_SUITE_data/basic_boolean.erl
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2014-03-03 01:40:39 +0100
committerKostis Sagonas <[email protected]>2015-12-16 22:08:32 +0100
commit9fd2f21c38944c8a605020d6662bb5935c5bbee2 (patch)
tree8f2dd4a13315d93e54eae79b2e1645fc439c1d58 /lib/hipe/test/basic_SUITE_data/basic_boolean.erl
parent82a835d94be7ee5e98d101a29999fedaf6cd75fe (diff)
downloadotp-9fd2f21c38944c8a605020d6662bb5935c5bbee2.tar.gz
otp-9fd2f21c38944c8a605020d6662bb5935c5bbee2.tar.bz2
otp-9fd2f21c38944c8a605020d6662bb5935c5bbee2.zip
First part of the basic test suite for the HiPE compiler
Diffstat (limited to 'lib/hipe/test/basic_SUITE_data/basic_boolean.erl')
-rw-r--r--lib/hipe/test/basic_SUITE_data/basic_boolean.erl47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/hipe/test/basic_SUITE_data/basic_boolean.erl b/lib/hipe/test/basic_SUITE_data/basic_boolean.erl
new file mode 100644
index 0000000000..e4a91ef5af
--- /dev/null
+++ b/lib/hipe/test/basic_SUITE_data/basic_boolean.erl
@@ -0,0 +1,47 @@
+%%% -*- erlang-indent-level: 2 -*-
+%%%-------------------------------------------------------------------
+%%% Author: Kostis Sagonas
+%%%
+%%% Tests for correct translation of booleans and their primitives.
+%%%-------------------------------------------------------------------
+-module(basic_boolean).
+
+-export([test/0]).
+
+test() ->
+ ok = test_boolean_ops(false, true),
+ ok = test_orelse_redundant(),
+ ok.
+
+%%--------------------------------------------------------------------
+
+test_boolean_ops(F, T) ->
+ true = T and T,
+ false = T and F,
+ false = F and T,
+ false = F and F,
+ true = T or T,
+ true = T or F,
+ true = F or T,
+ false = F or F,
+ true = T andalso T,
+ false = T andalso F,
+ false = F andalso T,
+ false = F andalso F,
+ true = T orelse T,
+ true = T orelse F,
+ true = F orelse T,
+ false = F orelse F,
+ ok.
+
+%%--------------------------------------------------------------------
+%% Redundant test in BEAM code will generate type warning.
+
+test_orelse_redundant() ->
+ true = test_orelse(true, true, true),
+ ok.
+
+test_orelse(A, B, C) ->
+ A andalso B orelse C.
+
+%%--------------------------------------------------------------------