From f2abb08616e4fe2b2f8ea457728e33c91ef5e83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Fri, 31 Jan 2014 13:20:04 +0100 Subject: compiler: Strengthen listings tests --- lib/compiler/test/compile_SUITE_data/small.erl | 48 ++++++++++++++++++++++ .../test/compile_SUITE_data/small_maps.erl | 16 ++++++++ 2 files changed, 64 insertions(+) create mode 100644 lib/compiler/test/compile_SUITE_data/small.erl create mode 100644 lib/compiler/test/compile_SUITE_data/small_maps.erl (limited to 'lib/compiler/test/compile_SUITE_data') diff --git a/lib/compiler/test/compile_SUITE_data/small.erl b/lib/compiler/test/compile_SUITE_data/small.erl new file mode 100644 index 0000000000..37cd270e50 --- /dev/null +++ b/lib/compiler/test/compile_SUITE_data/small.erl @@ -0,0 +1,48 @@ +-module(small). + +-export([go/0,go/2]). + + +-small_attribute({value,3}). + +go() -> go(3, 3.0). +go(A,B) -> + V1 = A + B, + V2 = A * B, + V3 = V1 / V2, + V4 = V3 / 0.3, + V5 = V1 + V2 + V3 + V4, + try + R = call(<<"wazzup">>, A), + {A,B,V5,R,t(),recv()} + catch + C:E -> + {error, C, E} + end. + +-spec call(binary(), term()) -> binary(). + +call(<<"wa", B/binary>>,V) when is_integer(V) -> B; +call(B,_) -> B. + +t() -> + <<23:32, V:14, _:2, B/binary>> = id(<<"wazzup world">>), + {V,B}. + +recv() -> + F = fun() -> + receive + 1 -> ok; + 2 -> ok; + 3 -> ok; + a -> ok; + _ -> none + after 0 -> tmo + end + end, + tmo = F(), + ok. + + +id(I) -> I. + diff --git a/lib/compiler/test/compile_SUITE_data/small_maps.erl b/lib/compiler/test/compile_SUITE_data/small_maps.erl new file mode 100644 index 0000000000..a17a136a7d --- /dev/null +++ b/lib/compiler/test/compile_SUITE_data/small_maps.erl @@ -0,0 +1,16 @@ +-module(small_maps). + +-export([go/0,go/1]). + +go() -> + go(1337). + +go(V0) -> + M0 = #{ a => 1, val => V0}, + V1 = get_val(M0), + M1 = M0#{ val := [V0,V1] }, + {some_val,[1337,{some_val,1337}]} = get_val(M1), + ok. + +get_val(#{ "wazzup" := _, val := V}) -> V; +get_val(#{ val := V }) -> {some_val, V}. -- cgit v1.2.3