diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-03-15 14:50:11 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-03-15 14:54:02 +0000 |
commit | d613e26ebd67b704ab58c28cc559ee01ae03b547 (patch) | |
tree | 96e484695221b0a39dee2ffc51aa0c0b7249d87e /gen/bool.erl | |
parent | 1ce9a14ba69c593bb40998a5a49d3f066a4aa07a (diff) | |
download | gleam_stdlib-d613e26ebd67b704ab58c28cc559ee01ae03b547.tar.gz gleam_stdlib-d613e26ebd67b704ab58c28cc559ee01ae03b547.zip |
Erase directly called capture funs
Diffstat (limited to 'gen/bool.erl')
-rw-r--r-- | gen/bool.erl | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/gen/bool.erl b/gen/bool.erl index 01c81ce..a02edc8 100644 --- a/gen/bool.erl +++ b/gen/bool.erl @@ -2,7 +2,22 @@ -compile(no_auto_import). -include_lib("eunit/include/eunit.hrl"). --export([max/2, min/2, to_int/1]). +-export([negate/1, max/2, min/2, to_int/1]). + +negate(Bool) -> + case Bool of + true -> + false; + + false -> + true + end. + +-ifdef(TEST). +negate_test() -> + expect:false(negate(true)), + expect:true(negate(false)). +-endif. max(A, B) -> case A of @@ -15,10 +30,10 @@ max(A, B) -> -ifdef(TEST). max_test() -> - (fun(Capture1) -> expect:equal(Capture1, true) end)(max(true, true)), - (fun(Capture1) -> expect:equal(Capture1, true) end)(max(true, false)), - (fun(Capture1) -> expect:equal(Capture1, false) end)(max(false, false)), - (fun(Capture1) -> expect:equal(Capture1, true) end)(max(false, true)). + expect:equal(max(true, true), true), + expect:equal(max(true, false), true), + expect:equal(max(false, false), false), + expect:equal(max(false, true), true). -endif. min(A, B) -> @@ -32,10 +47,10 @@ min(A, B) -> -ifdef(TEST). min_test() -> - (fun(Capture1) -> expect:equal(Capture1, true) end)(min(true, true)), - (fun(Capture1) -> expect:equal(Capture1, false) end)(min(true, false)), - (fun(Capture1) -> expect:equal(Capture1, false) end)(min(false, false)), - (fun(Capture1) -> expect:equal(Capture1, false) end)(min(false, true)). + expect:equal(min(true, true), true), + expect:equal(min(true, false), false), + expect:equal(min(false, false), false), + expect:equal(min(false, true), false). -endif. to_int(Bool) -> @@ -49,6 +64,6 @@ to_int(Bool) -> -ifdef(TEST). to_int_test() -> - (fun(Capture1) -> expect:equal(Capture1, 1) end)(to_int(true)), - (fun(Capture1) -> expect:equal(Capture1, 0) end)(to_int(false)). + expect:equal(to_int(true), 1), + expect:equal(to_int(false), 0). -endif. |