diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-07-03 09:50:21 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-07-03 09:53:25 +0100 |
commit | fa47fcb49980b1b1a2b2982389006345658bae79 (patch) | |
tree | 4c168df0a645ed7db2e06aadfbbdbd0a1d0aa9bf /gen/test/gleam@list_test.erl | |
parent | 02fd6d96e60d1a578193744a7799178755e37fde (diff) | |
download | gleam_stdlib-fa47fcb49980b1b1a2b2982389006345658bae79.tar.gz gleam_stdlib-fa47fcb49980b1b1a2b2982389006345658bae79.zip |
Improve erl formatting
Diffstat (limited to 'gen/test/gleam@list_test.erl')
-rw-r--r-- | gen/test/gleam@list_test.erl | 188 |
1 files changed, 120 insertions, 68 deletions
diff --git a/gen/test/gleam@list_test.erl b/gen/test/gleam@list_test.erl index eda42d4..942bee8 100644 --- a/gen/test/gleam@list_test.erl +++ b/gen/test/gleam@list_test.erl @@ -33,17 +33,25 @@ tail_test() -> filter_test() -> gleam@expect:equal(gleam@list:filter([], fun(_) -> true end), []), - gleam@expect:equal(gleam@list:filter([0, 4, 5, 7, 3], fun(_) -> true end), - [0, 4, 5, 7, 3]), - gleam@expect:equal(gleam@list:filter([0, 4, 5, 7, 3], fun(X) -> X > 4 end), - [5, 7]), - gleam@expect:equal(gleam@list:filter([0, 4, 5, 7, 3], fun(X) -> X < 4 end), - [0, 3]). + gleam@expect:equal( + gleam@list:filter([0, 4, 5, 7, 3], fun(_) -> true end), + [0, 4, 5, 7, 3] + ), + gleam@expect:equal( + gleam@list:filter([0, 4, 5, 7, 3], fun(X) -> X > 4 end), + [5, 7] + ), + gleam@expect:equal( + gleam@list:filter([0, 4, 5, 7, 3], fun(X) -> X < 4 end), + [0, 3] + ). map_test() -> gleam@expect:equal(gleam@list:map([], fun(X) -> X * 2 end), []), - gleam@expect:equal(gleam@list:map([0, 4, 5, 7, 3], fun(X) -> X * 2 end), - [0, 8, 10, 14, 6]). + gleam@expect:equal( + gleam@list:map([0, 4, 5, 7, 3], fun(X) -> X * 2 end), + [0, 8, 10, 14, 6] + ). traverse_test() -> Fun = fun(X) -> case X =:= 6 orelse X =:= 5 orelse X =:= 4 of @@ -53,8 +61,10 @@ traverse_test() -> false -> {error, X} end end, - gleam@expect:equal(gleam@list:traverse([5, 6, 5, 6], Fun), - {ok, [10, 12, 10, 12]}), + gleam@expect:equal( + gleam@list:traverse([5, 6, 5, 6], Fun), + {ok, [10, 12, 10, 12]} + ), gleam@expect:equal(gleam@list:traverse([4, 6, 5, 7, 3], Fun), {error, 7}). drop_test() -> @@ -63,8 +73,10 @@ drop_test() -> take_test() -> gleam@expect:equal(gleam@list:take([], 5), []), - gleam@expect:equal(gleam@list:take([1, 2, 3, 4, 5, 6, 7, 8], 5), - [1, 2, 3, 4, 5]). + gleam@expect:equal( + gleam@list:take([1, 2, 3, 4, 5, 6, 7, 8], 5), + [1, 2, 3, 4, 5] + ). new_test() -> gleam@expect:equal(gleam@list:new(), []). @@ -79,16 +91,16 @@ flatten_test() -> gleam@expect:equal(gleam@list:flatten([[1, 2], [], [3, 4]]), [1, 2, 3, 4]). fold_test() -> - gleam@expect:equal(gleam@list:fold([1, 2, 3], - [], - fun(X, Acc) -> [X | Acc] end), - [3, 2, 1]). + gleam@expect:equal( + gleam@list:fold([1, 2, 3], [], fun(X, Acc) -> [X | Acc] end), + [3, 2, 1] + ). fold_right_test() -> - gleam@expect:equal(gleam@list:fold_right([1, 2, 3], - [], - fun(X, Acc) -> [X | Acc] end), - [1, 2, 3]). + gleam@expect:equal( + gleam@list:fold_right([1, 2, 3], [], fun(X, Acc) -> [X | Acc] end), + [1, 2, 3] + ). find_test() -> F = fun(X) -> case X of @@ -103,32 +115,44 @@ find_test() -> gleam@expect:is_error(gleam@list:find([1, 3], F)). all_test() -> - gleam@expect:equal(gleam@list:all([1, 2, 3, 4, 5], fun(X) -> X > 0 end), - true), - gleam@expect:equal(gleam@list:all([1, 2, 3, 4, 5], fun(X) -> X < 0 end), - false), + gleam@expect:equal( + gleam@list:all([1, 2, 3, 4, 5], fun(X) -> X > 0 end), + true + ), + gleam@expect:equal( + gleam@list:all([1, 2, 3, 4, 5], fun(X) -> X < 0 end), + false + ), gleam@expect:equal(gleam@list:all([], fun(_) -> false end), true). any_test() -> - gleam@expect:equal(gleam@list:any([1, 2, 3, 4, 5], fun(X) -> X =:= 2 end), - true), - gleam@expect:equal(gleam@list:any([1, 2, 3, 4, 5], fun(X) -> X < 0 end), - false), + gleam@expect:equal( + gleam@list:any([1, 2, 3, 4, 5], fun(X) -> X =:= 2 end), + true + ), + gleam@expect:equal( + gleam@list:any([1, 2, 3, 4, 5], fun(X) -> X < 0 end), + false + ), gleam@expect:equal(gleam@list:any([], fun(_) -> false end), false). zip_test() -> gleam@expect:equal(gleam@list:zip([], [1, 2, 3]), []), gleam@expect:equal(gleam@list:zip([1, 2], []), []), - gleam@expect:equal(gleam@list:zip([1, 2, 3], [4, 5, 6]), - [{1, 4}, {2, 5}, {3, 6}]), + gleam@expect:equal( + gleam@list:zip([1, 2, 3], [4, 5, 6]), + [{1, 4}, {2, 5}, {3, 6}] + ), gleam@expect:equal(gleam@list:zip([5, 6], [1, 2, 3]), [{5, 1}, {6, 2}]), gleam@expect:equal(gleam@list:zip([5, 6, 7], [1, 2]), [{5, 1}, {6, 2}]). strict_zip_test() -> gleam@expect:is_error(gleam@list:strict_zip([], [1, 2, 3])), gleam@expect:is_error(gleam@list:strict_zip([1, 2], [])), - gleam@expect:equal(gleam@list:strict_zip([1, 2, 3], [4, 5, 6]), - {ok, [{1, 4}, {2, 5}, {3, 6}]}), + gleam@expect:equal( + gleam@list:strict_zip([1, 2, 3], [4, 5, 6]), + {ok, [{1, 4}, {2, 5}, {3, 6}]} + ), gleam@expect:is_error(gleam@list:strict_zip([5, 6], [1, 2, 3])), gleam@expect:is_error(gleam@list:strict_zip([5, 6, 7], [1, 2])). @@ -143,25 +167,35 @@ at_test() -> gleam@expect:is_error(gleam@list:at([1, 2, 3, 4, 5, 6], -1)). unique_test() -> - gleam@expect:equal(gleam@list:unique([1, 1, 2, 3, 4, 4, 4, 5, 6]), - [1, 2, 3, 4, 5, 6]), - gleam@expect:equal(gleam@list:unique([7, 1, 45, 6, 2, 47, 2, 7, 5]), - [7, 1, 45, 6, 2, 47, 5]), + gleam@expect:equal( + gleam@list:unique([1, 1, 2, 3, 4, 4, 4, 5, 6]), + [1, 2, 3, 4, 5, 6] + ), + gleam@expect:equal( + gleam@list:unique([7, 1, 45, 6, 2, 47, 2, 7, 5]), + [7, 1, 45, 6, 2, 47, 5] + ), gleam@expect:equal(gleam@list:unique([3, 4, 5]), [3, 4, 5]), gleam@expect:equal(gleam@list:unique([]), []). sort_test() -> gleam@expect:equal(gleam@list:sort([4, 3, 6, 5, 4]), [3, 4, 4, 5, 6]), gleam@expect:equal(gleam@list:sort([]), []), - gleam@expect:equal(gleam@list:sort([{1, 2}, {4, 5}, {3, 2}]), - [{1, 2}, {3, 2}, {4, 5}]). + gleam@expect:equal( + gleam@list:sort([{1, 2}, {4, 5}, {3, 2}]), + [{1, 2}, {3, 2}, {4, 5}] + ). index_map_test() -> - gleam@expect:equal(gleam@list:index_map([3, 4, 5], fun(I, X) -> {I, X} end), - [{0, 3}, {1, 4}, {2, 5}]), + gleam@expect:equal( + gleam@list:index_map([3, 4, 5], fun(I, X) -> {I, X} end), + [{0, 3}, {1, 4}, {2, 5}] + ), F = fun(I, X) -> gleam@string:append(X, gleam@int:to_string(I)) end, - gleam@expect:equal(gleam@list:index_map([<<"a">>, <<"b">>, <<"c">>], F), - [<<"a0">>, <<"b1">>, <<"c2">>]). + gleam@expect:equal( + gleam@list:index_map([<<"a">>, <<"b">>, <<"c">>], F), + [<<"a0">>, <<"b1">>, <<"c2">>] + ). range_test() -> gleam@expect:equal(gleam@list:range(0, 0), []), @@ -175,34 +209,52 @@ repeat_test() -> gleam@expect:equal(gleam@list:repeat(1, -10), []), gleam@expect:equal(gleam@list:repeat(1, 0), []), gleam@expect:equal(gleam@list:repeat(2, 3), [2, 2, 2]), - gleam@expect:equal(gleam@list:repeat(<<"x">>, 5), - [<<"x">>, <<"x">>, <<"x">>, <<"x">>, <<"x">>]). + gleam@expect:equal( + gleam@list:repeat(<<"x">>, 5), + [<<"x">>, <<"x">>, <<"x">>, <<"x">>, <<"x">>] + ). split_test() -> gleam@expect:equal(gleam@list:split([], 0), {[], []}), - gleam@expect:equal(gleam@list:split([0, 1, 2, 3, 4], 0), - {[], [0, 1, 2, 3, 4]}), - gleam@expect:equal(gleam@list:split([0, 1, 2, 3, 4], -2), - {[], [0, 1, 2, 3, 4]}), - gleam@expect:equal(gleam@list:split([0, 1, 2, 3, 4], 1), - {[0], [1, 2, 3, 4]}), - gleam@expect:equal(gleam@list:split([0, 1, 2, 3, 4], 3), - {[0, 1, 2], [3, 4]}), - gleam@expect:equal(gleam@list:split([0, 1, 2, 3, 4], 9), - {[0, 1, 2, 3, 4], []}). + gleam@expect:equal( + gleam@list:split([0, 1, 2, 3, 4], 0), + {[], [0, 1, 2, 3, 4]} + ), + gleam@expect:equal( + gleam@list:split([0, 1, 2, 3, 4], -2), + {[], [0, 1, 2, 3, 4]} + ), + gleam@expect:equal( + gleam@list:split([0, 1, 2, 3, 4], 1), + {[0], [1, 2, 3, 4]} + ), + gleam@expect:equal( + gleam@list:split([0, 1, 2, 3, 4], 3), + {[0, 1, 2], [3, 4]} + ), + gleam@expect:equal( + gleam@list:split([0, 1, 2, 3, 4], 9), + {[0, 1, 2, 3, 4], []} + ). split_while_test() -> - gleam@expect:equal(gleam@list:split_while([], fun(X) -> X =< 5 end), - {[], []}), - gleam@expect:equal(gleam@list:split_while([1, 2, 3, 4, 5], - fun(X) -> X =< 5 end), - {[1, 2, 3, 4, 5], []}), - gleam@expect:equal(gleam@list:split_while([1, 2, 3, 4, 5], - fun(X) -> X =:= 2 end), - {[], [1, 2, 3, 4, 5]}), - gleam@expect:equal(gleam@list:split_while([1, 2, 3, 4, 5], - fun(X) -> X =< 3 end), - {[1, 2, 3], [4, 5]}), - gleam@expect:equal(gleam@list:split_while([1, 2, 3, 4, 5], - fun(X) -> X =< -3 end), - {[], [1, 2, 3, 4, 5]}). + gleam@expect:equal( + gleam@list:split_while([], fun(X) -> X =< 5 end), + {[], []} + ), + gleam@expect:equal( + gleam@list:split_while([1, 2, 3, 4, 5], fun(X) -> X =< 5 end), + {[1, 2, 3, 4, 5], []} + ), + gleam@expect:equal( + gleam@list:split_while([1, 2, 3, 4, 5], fun(X) -> X =:= 2 end), + {[], [1, 2, 3, 4, 5]} + ), + gleam@expect:equal( + gleam@list:split_while([1, 2, 3, 4, 5], fun(X) -> X =< 3 end), + {[1, 2, 3], [4, 5]} + ), + gleam@expect:equal( + gleam@list:split_while([1, 2, 3, 4, 5], fun(X) -> X =< -3 end), + {[], [1, 2, 3, 4, 5]} + ). |