aboutsummaryrefslogtreecommitdiff
path: root/gen/result.erl
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-03-10 20:07:37 +0000
committerLouis Pilfold <louis@lpil.uk>2019-03-10 20:07:37 +0000
commit2a7d9061e4ec9c763053b078db2d98400bd08dd5 (patch)
treea6f36c30dc08db6a85cd1dad4b99031380e81832 /gen/result.erl
parentd74af16e6a527f46730c3d35554ef55677c9caf4 (diff)
downloadgleam_stdlib-2a7d9061e4ec9c763053b078db2d98400bd08dd5.tar.gz
gleam_stdlib-2a7d9061e4ec9c763053b078db2d98400bd08dd5.zip
Surround Fn's in parens if called directly
Closes https://github.com/lpil/gleam/issues/88
Diffstat (limited to 'gen/result.erl')
-rw-r--r--gen/result.erl68
1 files changed, 35 insertions, 33 deletions
diff --git a/gen/result.erl b/gen/result.erl
index d3337e2..9bbf1e1 100644
--- a/gen/result.erl
+++ b/gen/result.erl
@@ -44,12 +44,12 @@ map(Result, Fun) ->
-ifdef(TEST).
map_test() ->
- _ = fun(Capture1) ->
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {ok, 2})
- end(fun(Capture1) -> map(Capture1, fun(X) -> X + 1 end) end({ok, 1})),
- fun(Capture1) ->
+ end)((fun(Capture1) -> map(Capture1, fun(X) -> X + 1 end) end)({ok, 1})),
+ (fun(Capture1) ->
expect:equal(Capture1, {error, 1})
- end(fun(Capture1) -> map(Capture1, fun(X) -> X + 1 end) end({error, 1})).
+ end)((fun(Capture1) -> map(Capture1, fun(X) -> X + 1 end) end)({error, 1})).
-endif.
map_error(Result, Fun) ->
@@ -63,14 +63,16 @@ map_error(Result, Fun) ->
-ifdef(TEST).
map_error_test() ->
- _ = fun(Capture1) ->
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {ok, 1})
- end(fun(Capture1) -> map_error(Capture1, fun(X) -> X + 1 end) end({ok, 1})),
- fun(Capture1) ->
+ end)((fun(Capture1) ->
+ map_error(Capture1, fun(X) -> X + 1 end)
+ end)({ok, 1})),
+ (fun(Capture1) ->
expect:equal(Capture1, {error, 2})
- end(fun(Capture1) ->
- map_error(Capture1, fun(X) -> X + 1 end)
- end({error, 1})).
+ end)((fun(Capture1) ->
+ map_error(Capture1, fun(X) -> X + 1 end)
+ end)({error, 1})).
-endif.
flatten(Result) ->
@@ -84,18 +86,18 @@ flatten(Result) ->
-ifdef(TEST).
flatten_test() ->
- _ = fun(Capture1) ->
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {ok, 1})
- end(flatten({ok, {ok, 1}})),
- _ = fun(Capture1) ->
+ end)(flatten({ok, {ok, 1}})),
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {error, 1})
- end(flatten({ok, {error, 1}})),
- _ = fun(Capture1) ->
+ end)(flatten({ok, {error, 1}})),
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {error, 1})
- end(flatten({error, 1})),
- fun(Capture1) ->
+ end)(flatten({error, 1})),
+ (fun(Capture1) ->
expect:equal(Capture1, {error, {error, 1}})
- end(flatten({error, {error, 1}})).
+ end)(flatten({error, {error, 1}})).
-endif.
flat_map(Result, Fun) ->
@@ -115,21 +117,21 @@ flat_map(Result, Fun) ->
-ifdef(TEST).
flat_map_test() ->
- _ = fun(Capture1) ->
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {error, 1})
- end(fun(Capture1) ->
- flat_map(Capture1, fun(X) -> {ok, X + 1} end)
- end({error, 1})),
- _ = fun(Capture1) ->
+ end)((fun(Capture1) ->
+ flat_map(Capture1, fun(X) -> {ok, X + 1} end)
+ end)({error, 1})),
+ _ = (fun(Capture1) ->
expect:equal(Capture1, {ok, 2})
- end(fun(Capture1) ->
- flat_map(Capture1, fun(X) -> {ok, X + 1} end)
- end({ok, 1})),
- fun(Capture1) ->
+ end)((fun(Capture1) ->
+ flat_map(Capture1, fun(X) -> {ok, X + 1} end)
+ end)({ok, 1})),
+ (fun(Capture1) ->
expect:equal(Capture1, {error, 1})
- end(fun(Capture1) ->
- flat_map(Capture1, fun(Unused) -> {error, 1} end)
- end({ok, 1})).
+ end)((fun(Capture1) ->
+ flat_map(Capture1, fun(Unused) -> {error, 1} end)
+ end)({ok, 1})).
-endif.
unwrap(Result, Default) ->
@@ -143,8 +145,8 @@ unwrap(Result, Default) ->
-ifdef(TEST).
unwrap_test() ->
- _ = fun(Capture1) -> expect:equal(Capture1, 1) end(unwrap({ok, 1}, 50)),
- fun(Capture1) ->
+ _ = (fun(Capture1) -> expect:equal(Capture1, 1) end)(unwrap({ok, 1}, 50)),
+ (fun(Capture1) ->
expect:equal(Capture1, 50)
- end(unwrap({error, <<"nope">>}, 50)).
+ end)(unwrap({error, <<"nope">>}, 50)).
-endif.