Skip to content

Commit 42a3e98

Browse files
committed
Reformat tests
Apply erlfmt using `rebar3 fmt`.
1 parent e4dc9c3 commit 42a3e98

File tree

270 files changed

+2047
-1604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+2047
-1604
lines changed

tests/erlang_tests/alisp.erl

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
-export([run/1, start/0, eval/1, put_vars/1]).
2424

2525
start() ->
26-
run("(let ((y -1))
27-
(do ((i 0 (+ 1 i))) ((> i 2) y)
28-
(let ((x (+ 39 1)))
29-
(cond
30-
((= (+ 7 (+ (quote 5) 2)) 13) (0))
31-
((= 1 1) (setq y (+ x i)))
32-
((= 1 0) (-1))))))").
26+
run(
27+
"(let ((y -1))\n"
28+
" (do ((i 0 (+ 1 i))) ((> i 2) y)\n"
29+
" (let ((x (+ 39 1)))\n"
30+
" (cond\n"
31+
" ((= (+ 7 (+ (quote 5) 2)) 13) (0))\n"
32+
" ((= 1 1) (setq y (+ x i)))\n"
33+
" ((= 1 0) (-1))))))"
34+
).
3335

3436
run(S) ->
3537
L = sexp_lexer:string(S),
@@ -41,54 +43,43 @@ eval(S) when is_atom(S) ->
4143
undefined -> throw(unbound);
4244
Val -> Val
4345
end;
44-
4546
eval(I) when is_integer(I) ->
4647
I;
47-
4848
eval([do, Vars, [_TestExpr, _ReturnExpr] | _Exprs] = Do) ->
4949
Restore = put_do_vars(Vars),
5050
execute_do(Do, Restore);
51-
5251
eval(['let', Vars | Exprs]) ->
5352
Restore = put_vars(Vars),
5453
Res = eval_list(Exprs),
5554
_ = delete_vars(Vars),
5655
_ = restore_vars(Restore),
5756
Res;
58-
5957
eval([quote, Args]) ->
6058
Args;
61-
6259
eval(['cond' | Exps]) ->
6360
eval_cond_tests(Exps);
64-
6561
eval(['progn' | Exprs]) ->
6662
eval_list(Exprs);
67-
6863
eval(['setq', Name, Expr]) ->
6964
Val = eval(Expr),
7065
put(Name, Val),
7166
Val;
72-
7367
eval([Fn | Args]) when is_atom(Fn) ->
7468
EvaluatedArgs = eval_args(Args),
7569
func_eval(Fn, EvaluatedArgs).
7670

7771
func_eval('=', [Arg1, Arg2]) ->
7872
Arg1 == Arg2;
79-
8073
func_eval(Fn, EvaluatedArgs) ->
8174
fapply(erlang, Fn, EvaluatedArgs).
8275

8376
eval_args([]) ->
8477
[];
85-
8678
eval_args([A | T]) ->
8779
[eval(A) | eval_args(T)].
8880

8981
eval_cond_tests([]) ->
9082
[];
91-
9283
eval_cond_tests([[Test, Action] | T]) ->
9384
case eval(Test) of
9485
true -> eval(Action);
@@ -97,17 +88,14 @@ eval_cond_tests([[Test, Action] | T]) ->
9788

9889
eval_list([]) ->
9990
[];
100-
10191
eval_list([Exp]) ->
10292
eval(Exp);
103-
10493
eval_list([Exp | T]) ->
10594
eval(Exp),
10695
eval_list(T).
10796

10897
put_vars([]) ->
10998
[];
110-
11199
put_vars([[Name, Expr] | T]) ->
112100
Val = eval(Expr),
113101
case put(Name, Val) of
@@ -117,7 +105,6 @@ put_vars([[Name, Expr] | T]) ->
117105

118106
put_do_vars([]) ->
119107
[];
120-
121108
put_do_vars([[Name, Expr, _UpdateExpr] | T]) ->
122109
Val = eval(Expr),
123110
case put(Name, Val) of
@@ -127,28 +114,24 @@ put_do_vars([[Name, Expr, _UpdateExpr] | T]) ->
127114

128115
delete_vars([]) ->
129116
ok;
130-
131117
delete_vars([[Name, _Val] | T]) ->
132118
erase(Name),
133119
delete_vars(T).
134120

135121
delete_do_vars([]) ->
136122
ok;
137-
138123
delete_do_vars([[Name, _Val, _UpdateExpr] | T]) ->
139124
erase(Name),
140125
delete_do_vars(T).
141126

142127
restore_vars([]) ->
143128
ok;
144-
145129
restore_vars([{Name, Val} | T]) ->
146130
_ = put(Name, Val),
147131
restore_vars(T).
148132

149133
do_update_vars([]) ->
150134
[];
151-
152135
do_update_vars([[Name, _Expr, UpdateExpr] | T]) ->
153136
Val = eval(UpdateExpr),
154137
_ = put(Name, Val),
@@ -183,5 +166,6 @@ fapply(Module, Function, Args) ->
183166
Module:Function(Arg1, Arg2, Arg3, Arg4, Arg5);
184167
[Arg1, Arg2, Arg3, Arg4, Arg5, Arg6] ->
185168
Module:Function(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
186-
_ -> throw(badarg)
169+
_ ->
170+
throw(badarg)
187171
end.

tests/erlang_tests/bigfact.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ start() ->
2626
bigfact:factorial(20) div bigfact:factorial(15).
2727

2828
factorial(0) -> 1;
29-
factorial(N) -> N * factorial(N-1).
29+
factorial(N) -> N * factorial(N - 1).

tests/erlang_tests/bigfact2.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ start() ->
2626
abs(-factorial(20)) rem -(factorial(12) + 1).
2727

2828
factorial(0) -> 1;
29-
factorial(N) -> N * factorial(N-1).
29+
factorial(N) -> N * factorial(N - 1).

tests/erlang_tests/bigfact3.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ start() ->
2626
(factorial(20) - factorial(19)) rem (factorial(10) + 1).
2727

2828
factorial(0) -> 1;
29-
factorial(N) -> N * factorial(N-1).
29+
factorial(N) -> N * factorial(N - 1).

tests/erlang_tests/biggerdifference.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ diff1500(A) ->
3131
double(0) ->
3232
0;
3333
double(I) ->
34-
id(I)*2.
34+
id(I) * 2.
3535

3636
id(0) ->
3737
0;
@@ -44,4 +44,4 @@ willnotbecalled(I) ->
4444
2000 div I.
4545

4646
willnotbecalled(A, B) ->
47-
(A - B)*2 + 2047.
47+
(A - B) * 2 + 2047.

tests/erlang_tests/bin2float.erl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
%
2020

2121
-module(bin2float).
22+
2223
-export([start/0, id/1, bin2float/1, float_cmp/2]).
2324

2425
start() ->
@@ -31,15 +32,14 @@ start() ->
3132
F7 = bin2float(id(<<"1.0e-3">>)),
3233
F8 = bin2float(id(<<"0.0">>)),
3334
float_cmp(F1, id(1500.0)) +
34-
float_cmp(F2, id(1.5)) * 2 +
35-
float_cmp(F3, id(2.0)) * 4 +
36-
float_cmp(F4, id(1.0)) * 8 +
37-
float_cmp(F5, id(0.1)) * 16 +
38-
float_cmp(F6, id(1000.0)) * 32 +
39-
float_cmp(F7, id(0.001)) * 64 +
40-
float_cmp(F8, id(0.0)) * 128 +
41-
bin2float({}).
42-
35+
float_cmp(F2, id(1.5)) * 2 +
36+
float_cmp(F3, id(2.0)) * 4 +
37+
float_cmp(F4, id(1.0)) * 8 +
38+
float_cmp(F5, id(0.1)) * 16 +
39+
float_cmp(F6, id(1000.0)) * 32 +
40+
float_cmp(F7, id(0.001)) * 64 +
41+
float_cmp(F8, id(0.0)) * 128 +
42+
bin2float({}).
4343

4444
bin2float(F) ->
4545
try id(erlang:binary_to_float(F)) of
@@ -54,6 +54,7 @@ float_cmp(F1, F2) ->
5454
true -> 1;
5555
false -> 0
5656
end.
57+
5758
id(I) when is_float(I) ->
5859
I;
5960
id(I) when is_binary(I) ->

tests/erlang_tests/binary_at_test.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
-export([start/0, id/1, atp10/1]).
2424

2525
start() ->
26-
atp10(id(<<"HelloWorld">>)) + atp10safe(id(<<"">>)) + atp10safe(42) .
26+
atp10(id(<<"HelloWorld">>)) + atp10safe(id(<<"">>)) + atp10safe(42).
2727

2828
atp10(Bin) ->
2929
binary:at(Bin, 4) + 10.

tests/erlang_tests/binary_first_test.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ start() ->
2828
firstp10(Bin) ->
2929
binary:first(Bin) + 10.
3030

31-
3231
firstp10safe(Bin) ->
3332
try firstp10(Bin) of
3433
_Any -> 1

tests/erlang_tests/binary_is_iolist.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
%
2020

2121
-module(binary_is_iolist).
22+
2223
-export([start/0, id/1, try_size/1, try_to_bin/1]).
2324

2425
start() ->
@@ -28,10 +29,8 @@ start() ->
2829

2930
bool_to_int(true) ->
3031
1;
31-
3232
bool_to_int(false) ->
3333
0;
34-
3534
bool_to_int(_) ->
3635
-1.
3736

tests/erlang_tests/booleans2_test.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
1919
%
2020

21-
-module (booleans2_test).
21+
-module(booleans2_test).
22+
2223
-export([start/0, f/5, one_if_true/1]).
2324

2425
start() ->
2526
one_if_true(f(1, 1, 2, 3, 4)) +
26-
one_if_true(f(1, 2, 3, 3, 4)) +
27-
one_if_true(f(1, 2, 3, 4, 5)) +
28-
one_if_true(f(1, 1, 2, 2, 6)) +
29-
one_if_true(f(1, 1, 3, 4, 1)).
27+
one_if_true(f(1, 2, 3, 3, 4)) +
28+
one_if_true(f(1, 2, 3, 4, 5)) +
29+
one_if_true(f(1, 1, 2, 2, 6)) +
30+
one_if_true(f(1, 1, 3, 4, 1)).
3031

3132
f(A, B, C, D, E) ->
3233
((A == B) xor (C == D)) and (A /= E) and (C /= E).

0 commit comments

Comments
 (0)