1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
%% -*- Mode: erlang; indent-tabs-mode: nil -*-
%% Copyright Ericsson AB 2017. All Rights Reserved.
%%% indentation of terms contain builtin types
%%% 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
list(1) ->
[a,
b,
c
];
list(2) ->
[ a,
b, c
];
list(3) ->
[
a,
b, c
];
list(4) ->
[ a
, b
, c
].
tuple(1) ->
{a,
b,c
};
tuple(2) ->
{ a,
b,c
};
tuple(3) ->
{
a,
b,c
};
tuple(4) ->
{ a
, b
,c
}.
binary(1) ->
<<1:8,
2:8
>>;
binary(2) ->
<<
1:8,
2:8
>>;
binary(3) ->
<< 1:8,
2:8
>>;
binary(4) ->
<<
1:8
,2:8
>>.
record(1) ->
#record{a=1,
b=2
};
record(2) ->
#record{ a=1,
b=2
};
record(3) ->
#record{
a=1,
b=2
};
record(4) ->
#record{
a=1
,b=2
}.
map(1) ->
#{a=>1,
b=>2
};
map(2) ->
#{ a=>1,
b=>2
};
map(3) ->
#{
a=>1,
b=>2
};
map(4) ->
#{
a => <<"a">>
,b => 2
};
map(MapVar) ->
MapVar = #{a :=<<"a">>
,b:=1}.
deep(Rec) ->
Rec#rec{ atom = 'atom',
map = #{ k1 => {v,
1},
k2 => [
1,
2,
3
],
{key,
3}
=>
<<
123:8,
255:8
>>
}
}.
%% Record indentation
some_function_with_a_very_long_name() ->
#'a-long-record-name-like-it-sometimes-is-with-asn.1-records'{
field1=a,
field2=b},
case dummy_function_with_a_very_very_long_name(x) of
#'a-long-record-name-like-it-sometimes-is-with-asn.1-records'{
field1=a,
field2=b} ->
ok;
Var = #'a-long-record-name-like-it-sometimes-is-with-asn.1-records'{
field1=a,
field2=b} ->
Var#'a-long-record-name-like-it-sometimes-is-with-asn.1-records'{
field1=a,
field2=b};
#xyz{
a=1,
b=2} ->
ok
end.
some_function_name_xyz(xyzzy, #some_record{
field1=Field1,
field2=Field2}) ->
SomeVariable = f(#'Some-long-record-name'{
field_a = 1,
'inter-xyz-parameters' =
#'Some-other-very-long-record-name'{
field2 = Field1,
field2 = Field2}}),
{ok, SomeVariable}.
foo() ->
[#foo{
foo = foo}].
|