From 7dae40dd0d595776eec7c0407a7849962650e762 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Sun, 12 Jan 2014 20:10:49 +0100 Subject: Add tests for the HiPE compiler (Part 1: binaries and bitstrings) Create tests for the HiPE native code compiler. This is the first part of the effort and contains tests that check that the native code produced by the HiPE compiler for binaries and bitstrings is OK and behaves similarly to the code produced by the BEAM compiler. --- lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl (limited to 'lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl') diff --git a/lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl b/lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl new file mode 100644 index 0000000000..7b62a17cfb --- /dev/null +++ b/lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl @@ -0,0 +1,32 @@ +%% -*- erlang-indent-level: 2 -*- +%%------------------------------------------------------------------- +%% When executing this in R8 (and compiled with R8) the result was +%% {ok,[148,129,0,0]} but should be {ok,[145,148,113,129,0,0,0,0]} +%% Thanks to Kenneth Lundin for sending this to us. +%%------------------------------------------------------------------- + +-module(bs_bugs_R08). + +-export([test/0]). + +test() -> + List = [145,148,113,129,0,0,0,0], + {ok, List} = msisdn_internal_storage(<<145,148,113,129,0,0,0,0>>, []), + ok. + +%% msisdn_internal_storage/3 +%% Convert MSISDN binary to internal datatype (TBCD-octet list) + +msisdn_internal_storage(<<>>, MSISDN) -> + {ok, lists:reverse(MSISDN)}; +msisdn_internal_storage(<<2#11111111:8,_Rest/binary>>, MSISDN) -> + {ok, lists:reverse(MSISDN)}; +msisdn_internal_storage(<<2#1111:4,DigitN:4,_Rest/binary>>, MSISDN) when + DigitN < 10 -> + {ok, lists:reverse([(DigitN bor 2#11110000)|MSISDN])}; +msisdn_internal_storage(<>, MSISDN) when + DigitNplus1 < 10, DigitN < 10 -> + NewMSISDN = [((DigitNplus1 bsl 4) bor DigitN)|MSISDN], + msisdn_internal_storage(Rest, NewMSISDN); +msisdn_internal_storage(_Rest, _MSISDN) -> + {fault}. %% Mandatory IE incorrect -- cgit v1.2.3