diff options
author | Kostis Sagonas <[email protected]> | 2014-03-04 14:05:49 +0100 |
---|---|---|
committer | Kostis Sagonas <[email protected]> | 2015-12-16 22:08:32 +0100 |
commit | 6a645e07a02f9adda9b9534214e699ad8f30a15f (patch) | |
tree | 204668b974388eeb551ec14a4e52c7ee535acb92 /lib/hipe/test/basic_SUITE_data/basic_lists.erl | |
parent | 9fd2f21c38944c8a605020d6662bb5935c5bbee2 (diff) | |
download | otp-6a645e07a02f9adda9b9534214e699ad8f30a15f.tar.gz otp-6a645e07a02f9adda9b9534214e699ad8f30a15f.tar.bz2 otp-6a645e07a02f9adda9b9534214e699ad8f30a15f.zip |
More basic tests
and some tests that the HiPE compiler is not causing trouble
Diffstat (limited to 'lib/hipe/test/basic_SUITE_data/basic_lists.erl')
-rw-r--r-- | lib/hipe/test/basic_SUITE_data/basic_lists.erl | 22 |
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), |