aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/basic_SUITE_data/basic_lists.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hipe/test/basic_SUITE_data/basic_lists.erl')
-rw-r--r--lib/hipe/test/basic_SUITE_data/basic_lists.erl22
1 files changed, 21 insertions, 1 deletions
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),