diff options
author | Björn Gustavsson <[email protected]> | 2010-09-22 14:26:51 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-09-22 14:48:09 +0200 |
commit | d1d3de0e7e929e2f6f7bb47bbc3d67434f97926d (patch) | |
tree | 45c144ee3196547b353765348b10773d4779a03b /lib/compiler | |
parent | dc7d2319691fa599717c066460cce53ce97b6b18 (diff) | |
download | otp-d1d3de0e7e929e2f6f7bb47bbc3d67434f97926d.tar.gz otp-d1d3de0e7e929e2f6f7bb47bbc3d67434f97926d.tar.bz2 otp-d1d3de0e7e929e2f6f7bb47bbc3d67434f97926d.zip |
Add tests for tail segments in binary generators
Diffstat (limited to 'lib/compiler')
-rw-r--r-- | lib/compiler/test/bs_bincomp_SUITE.erl | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/compiler/test/bs_bincomp_SUITE.erl b/lib/compiler/test/bs_bincomp_SUITE.erl index a64a5d590b..74f69893af 100644 --- a/lib/compiler/test/bs_bincomp_SUITE.erl +++ b/lib/compiler/test/bs_bincomp_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. +%% Copyright Ericsson AB 2006-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 @@ -24,7 +24,7 @@ -export([all/1, byte_aligned/1,bit_aligned/1,extended_byte_aligned/1, extended_bit_aligned/1,mixed/1,filters/1,trim_coverage/1, - nomatch/1,sizes/1]). + nomatch/1,sizes/1,tail/1]). -include("test_server.hrl"). @@ -32,7 +32,7 @@ all(suite) -> test_lib:recompile(?MODULE), [byte_aligned,bit_aligned,extended_byte_aligned, extended_bit_aligned,mixed,filters,trim_coverage, - nomatch,sizes]. + nomatch,sizes,tail]. byte_aligned(Config) when is_list(Config) -> @@ -270,6 +270,38 @@ sizes(Config) when is_list(Config) -> ?line cs_end(), ok. +tail(Config) when is_list(Config) -> + ?line [] = tail_1(<<0:7>>), + ?line [0] = tail_1(<<0>>), + ?line [0] = tail_1(<<0:12>>), + ?line [0,0] = tail_1(<<0:20>>), + + ?line [] = tail_2(<<0:7>>), + ?line [42] = tail_2(<<0>>), + ?line [] = tail_2(<<0:12>>), + ?line [42,42] = tail_2(<<0,1>>), + + ?line <<>> = tail_3(<<0:7>>), + ?line <<42>> = tail_3(<<0>>), + ?line <<42>> = tail_3(<<0:12>>), + ?line <<42,42>> = tail_3(<<0:20>>), + + ?line [] = tail_4(<<0:15>>), + ?line [7] = tail_4(<<7,8>>), + ?line [9] = tail_4(<<9,17:12>>), + ok. + +tail_1(Bits) -> + [X || <<X:8/integer, _/bits>> <= Bits]. + +tail_2(Bits) -> + [42 || <<_:8/integer, _/bytes>> <= Bits]. + +tail_3(Bits) -> + << <<42>> || <<_:8/integer, _/bits>> <= Bits >>. + +tail_4(Bits) -> + [X || <<X:8/integer, Tail/bits>> <= Bits, bit_size(Tail) >= 8]. cs_init() -> |