aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-10-07 11:41:19 +0200
committerBjörn Gustavsson <[email protected]>2010-10-07 11:41:19 +0200
commit714415871fe2a03c63ba54932669bf2b7ed89a91 (patch)
treefd7aa9d202a181aa1460b004599adddc324f6d69 /lib/compiler/test
parent0f851e8dbfcc33ca31603409e21742455d37e3be (diff)
parent7b283aa9507b45f2cd403b061ad92ab059fb71b5 (diff)
downloadotp-714415871fe2a03c63ba54932669bf2b7ed89a91.tar.gz
otp-714415871fe2a03c63ba54932669bf2b7ed89a91.tar.bz2
otp-714415871fe2a03c63ba54932669bf2b7ed89a91.zip
Merge branch 'bjorn/compiler-bin-generators/OTP-8864' into dev
* bjorn/compiler-bin-generators/OTP-8864: core_lint: Enforce that tail segments only occur at the end Don't generate multiple tail segments in binary matching Factor out some of the code for binary generators Add tests for tail segments in binary generators
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/bs_bincomp_SUITE.erl38
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() ->