From aa9054e0ea48a127f2aeafcdce1df4d1aec09574 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 20 Dec 2017 10:33:56 +0100 Subject: Add emacs indention testcase Split the manual testcase and run them in daily tests instead. Easy to run directly as well: (cd ../test; cerl -eval "emacs_SUITE:indent([])") --- lib/tools/test/emacs_SUITE_data/funcs | 169 ++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 lib/tools/test/emacs_SUITE_data/funcs (limited to 'lib/tools/test/emacs_SUITE_data/funcs') diff --git a/lib/tools/test/emacs_SUITE_data/funcs b/lib/tools/test/emacs_SUITE_data/funcs new file mode 100644 index 0000000000..2ad9d73262 --- /dev/null +++ b/lib/tools/test/emacs_SUITE_data/funcs @@ -0,0 +1,169 @@ +%% -*- Mode: erlang; indent-tabs-mode: nil -*- +%% Copyright Ericsson AB 2017. All Rights Reserved. + +%%% Function (and funs) indentation + +%%% Not everything in these test are set in stone +%%% better indentation rules can be added but by having +%%% these tests we can see what changes in new implementations +%%% and notice when doing unintentional changes + +-export([ + func1/0, + func2/0, + a_function_with_a_very_very_long_name/0, + when1/2 + ]). + +-compile([nowarn_unused_functions, + {inline, [ + func2/2, + func3/2 + ] + } + ]). + +func1() -> + basic. + +func2(A1, + A2) -> + ok. + +func3( + A1, + A2 + ) -> + ok. + +%% Okeefe style +func4(A1 + ,A2 + ,A3 + ) -> + ok. + +a_function_with_a_very_very_long_name() -> + A00 = #record{ + field1=1, + field2=1 + }, + A00. + +when1(W1, W2) + when is_number(W1), + is_number(W2) -> + ok. + +when2(W1,W2,W3) when + W1 > W2, + W2 > W3 -> + ok. + +when3(W1,W2,W3) when + W1 > W2, + W2 > W3 + -> + ok. + +when4(W1,W2,W3) + when + W1 > W2, + W2 > W3 -> + ok. + +match1({[H|T], + Other}, + M1A2) -> + ok. + +match2( + { + [H|T], + Other + }, + M2A2 + ) -> + ok. + +match3({ + M3A1, + [ + H | + T + ], + Other + }, + M3A2 + ) -> + ok. + +match4(<< + M4A:8, + M4B:16/unsigned-integer, + _/binary + >>, + M4C) -> + ok. + +match5(M5A, + #record{ + b=M5B, + c=M5C + } + ) -> + ok. + +match6(M6A, + #{key6a := a6, + key6b := b6 + }) -> + ok. + +funs(1) + when + X -> + %% Changed fun to one indention level + %% 'when' and several clause forces a depth of '4' + Var = spawn(fun(X, _) + when X == 2; + X > 10 -> + hello, + case Hello() of + true when is_atom(X) -> + foo; + false -> + bar + end; + (Foo) when is_atom(Foo), + is_integer(X) -> + X = 6* 45, + Y = true andalso + kalle + end), + Var; +funs(2) -> + %% check EEP37 named funs + Fn1 = fun + Factory(N) when + N > 0 -> + F = Fact(N-1), + N * F; + Factory(0) -> + 1 + end, + Fn1; +funs(3) -> + %% check anonymous funs too + Fn2 = fun(0) -> + 1; + (N) -> + N + end, + ok; +funs(4) -> + X = lists:foldr(fun(M) -> + <> + end, [], Z), + A = <>, + A. -- cgit v1.2.3 From e57a6ec75ed99d4695fb8fcd31dd625483951687 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Tue, 9 Jan 2018 13:00:12 +0100 Subject: emacs: Indent tuple (and maps) elements as list elements Avoid From: { ^^element1, ^^element2 } To: { ^element1, ^element2 } --- lib/tools/test/emacs_SUITE_data/funcs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/tools/test/emacs_SUITE_data/funcs') diff --git a/lib/tools/test/emacs_SUITE_data/funcs b/lib/tools/test/emacs_SUITE_data/funcs index 2ad9d73262..b0c9716f0e 100644 --- a/lib/tools/test/emacs_SUITE_data/funcs +++ b/lib/tools/test/emacs_SUITE_data/funcs @@ -79,20 +79,20 @@ match1({[H|T], match2( { - [H|T], - Other + [H|T], + Other }, M2A2 ) -> ok. match3({ - M3A1, - [ - H | - T - ], - Other + M3A1, + [ + H | + T + ], + Other }, M3A2 ) -> -- cgit v1.2.3 From f0a74dfbaf87f65f6fe7f63fa63965a35fa30faa Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 10 Jan 2018 12:59:20 +0100 Subject: emacs: Indent delimiter first in term elements correctly --- lib/tools/test/emacs_SUITE_data/funcs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/tools/test/emacs_SUITE_data/funcs') diff --git a/lib/tools/test/emacs_SUITE_data/funcs b/lib/tools/test/emacs_SUITE_data/funcs index b0c9716f0e..f2c9f44524 100644 --- a/lib/tools/test/emacs_SUITE_data/funcs +++ b/lib/tools/test/emacs_SUITE_data/funcs @@ -43,6 +43,11 @@ func4(A1 ) -> ok. +func5( + A41 + ,A42) -> + ok. + a_function_with_a_very_very_long_name() -> A00 = #record{ field1=1, -- cgit v1.2.3 From 13f1dec0220d44e5178feb52cf076dbdebaa23a0 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 10 Jan 2018 16:23:05 +0100 Subject: emacs: delimiter first in icr works --- lib/tools/test/emacs_SUITE_data/funcs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/tools/test/emacs_SUITE_data/funcs') diff --git a/lib/tools/test/emacs_SUITE_data/funcs b/lib/tools/test/emacs_SUITE_data/funcs index f2c9f44524..877f982005 100644 --- a/lib/tools/test/emacs_SUITE_data/funcs +++ b/lib/tools/test/emacs_SUITE_data/funcs @@ -142,7 +142,7 @@ funs(1) end; (Foo) when is_atom(Foo), is_integer(X) -> - X = 6* 45, + X = 6 * 45, Y = true andalso kalle end), -- cgit v1.2.3