Summary: Add support for `if` expressions. Reviewed By: rgrig Differential Revision: D29637230 fbshipit-source-id: 5dee00345master
parent
88beede7dc
commit
e04bc38fde
@ -0,0 +1,33 @@
|
|||||||
|
% Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
%
|
||||||
|
% This source code is licensed under the MIT license found in the
|
||||||
|
% LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
-module(if_expression).
|
||||||
|
|
||||||
|
-export([
|
||||||
|
test_accepts_positive_Ok/0,
|
||||||
|
test_accepts_positive_Bad/0,
|
||||||
|
test_accepts_all_Ok/0
|
||||||
|
]).
|
||||||
|
|
||||||
|
accepts_positive(X) ->
|
||||||
|
if
|
||||||
|
X > 0 -> ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
accepts_all(X) ->
|
||||||
|
if
|
||||||
|
X > 0 -> ok;
|
||||||
|
not (X > 0) -> ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
test_accepts_positive_Ok() ->
|
||||||
|
accepts_positive(1).
|
||||||
|
|
||||||
|
test_accepts_positive_Bad() ->
|
||||||
|
accepts_positive(0).
|
||||||
|
|
||||||
|
test_accepts_all_Ok() ->
|
||||||
|
accepts_all(0),
|
||||||
|
accepts_all(1).
|
Loading…
Reference in new issue