From 6a645e07a02f9adda9b9534214e699ad8f30a15f Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Tue, 4 Mar 2014 14:05:49 +0100 Subject: More basic tests and some tests that the HiPE compiler is not causing trouble --- lib/hipe/test/basic_SUITE_data/basic_lists.erl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/hipe/test/basic_SUITE_data/basic_lists.erl') diff --git a/lib/hipe/test/basic_SUITE_data/basic_lists.erl b/lib/hipe/test/basic_SUITE_data/basic_lists.erl index d229467b84..264a7f86f6 100644 --- a/lib/hipe/test/basic_SUITE_data/basic_lists.erl +++ b/lib/hipe/test/basic_SUITE_data/basic_lists.erl @@ -2,7 +2,8 @@ %%%------------------------------------------------------------------- %%% Author: Kostis Sagonas %%% -%%% Contains tests that manipulate and pattern match against lists. +%%% Contains tests that manipulate and pattern match against lists +%%% (perhaps by calling functions from the 'lists' module). %%%------------------------------------------------------------------- -module(basic_lists). @@ -10,6 +11,7 @@ test() -> ok = test_length(), + ok = test_lists_key(), ok = test_lists_and_strings(), ok. @@ -32,6 +34,24 @@ len([], L) -> L. %%-------------------------------------------------------------------- +test_lists_key() -> + First = {x, 42.0}, + Second = {y, -77}, + Third = {z, [a, b, c], {5.0}}, + List = [First, Second, Third], + {value, First} = key_search_find(42, 2, List), + ok. + +key_search_find(Key, Pos, List) -> + case lists:keyfind(Key, Pos, List) of + false -> + false = lists:keysearch(Key, Pos, List); + Tuple when is_tuple(Tuple) -> + {value, Tuple} = lists:keysearch(Key, Pos, List) + end. + +%%-------------------------------------------------------------------- + test_lists_and_strings() -> LL = ["H'A", " H'B", " H'C"], LL2 = lists:map(fun string:strip/1, LL), -- cgit v1.2.3