diff options
Diffstat (limited to 'lib/compiler/test/andor_SUITE.erl')
-rw-r--r-- | lib/compiler/test/andor_SUITE.erl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/compiler/test/andor_SUITE.erl b/lib/compiler/test/andor_SUITE.erl index 5c463063c1..7232eb0ffd 100644 --- a/lib/compiler/test/andor_SUITE.erl +++ b/lib/compiler/test/andor_SUITE.erl @@ -66,6 +66,17 @@ t_case(Config) when is_list(Config) -> true = (catch t_case_e({a,b}, {a,b})), false = (catch t_case_e({a,b}, 42)), + {true,false} = t_case_f1(true, pos), + {false,true} = t_case_f1(true, whatever), + {false,true} = t_case_f1(false, pos), + {false,true} = t_case_f1(false, whatever), + {false,false} = t_case_f1(not_boolean, pos), + {false,false} = t_case_f1(not_boolean, whatever), + + false = t_case_f2(true), + true = t_case_f2(false), + false = t_case_f2(whatever), + true = t_case_xy(42, 100, 700), true = t_case_xy(42, 100, whatever), false = t_case_xy(42, wrong, 700), @@ -109,6 +120,25 @@ t_case_e(A, B) -> Bool when is_tuple(A) -> id(Bool) end. +t_case_f1(IsInt, Eval) -> + B = case IsInt of + true -> Eval =:= pos; + false -> false; + _ -> IsInt + end, + + %% The above is the same as `IsInt andalso Eval =:= pos` in a guard. + %% In a real guard, variable `B` will only be used once. + {B =:= true, B =:= false}. + +t_case_f2(IsInt) -> + B = case IsInt of + true -> false; + false -> true; + _ -> IsInt + end, + B =:= true. + t_case_xy(X, Y, Z) -> Res = t_case_x(X, Y, Z), Res = t_case_y(X, Y, Z). |