aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/bs_SUITE_data/bs_save.erl
blob: fe2b1105f24fb16cb49305cb236b2d4439fefc90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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(<<H, T/binary>>, Av, Al, Len) ->
  inc_on_ones(T, 0, [((Av bsl 7) bor H)|Al], Len-1).