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_save.erl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/hipe/test/bs_SUITE_data/bs_save.erl (limited to 'lib/hipe/test/bs_SUITE_data/bs_save.erl') diff --git a/lib/hipe/test/bs_SUITE_data/bs_save.erl b/lib/hipe/test/bs_SUITE_data/bs_save.erl new file mode 100644 index 0000000000..fe2b1105f2 --- /dev/null +++ b/lib/hipe/test/bs_SUITE_data/bs_save.erl @@ -0,0 +1,21 @@ +%%% -*- erlang-indent-level: 2 -*- +%%%------------------------------------------------------------------- +%%% File : bs_save.erl +%%% Author : Per Gustafsson +%%% Purpose : Tests that compilation works for bs_save +%%% Created : 1 Nov 2007 +%%%------------------------------------------------------------------- +-module(bs_save). + +-export([test/0]). + +test() -> + {[16257, 1], <<0>>} = inc_on_ones(<<255,1,128,1,128,0>>, 0, [], 5), + ok. + +inc_on_ones(Buffer, _Av, Al, 0) -> + {lists:reverse(Al), Buffer}; +inc_on_ones(<<1:1, H:7, T/binary>>, Av, Al, Len) -> + inc_on_ones(T, (Av bsl 7) bor H, Al, Len-1); +inc_on_ones(<>, Av, Al, Len) -> + inc_on_ones(T, 0, [((Av bsl 7) bor H)|Al], Len-1). -- cgit v1.2.3