Skip to content

Commit

Permalink
Add support for andalso/orelse in tests
Browse files Browse the repository at this point in the history
Summary: Add `andalso` and `orelse` to binary operators supported in elaboration of guards.

Reviewed By: RobinMorisset

Differential Revision: D41336885

fbshipit-source-id: 8de6d61df01377d9410535083e043e6f5b0f591f
  • Loading branch information
VLanvin authored and facebook-github-bot committed Nov 18, 2022
1 parent c7d16c8 commit d8afa8e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ final class ElabGuard(pipelineContext: PipelineContext) {
(booleanType, env2)
case ">=" | ">" | "=<" | "<" | "/=" | "=/=" | "==" | "=:=" =>
(booleanType, elabComparison(binOp, env))
case "andalso" =>
val env1 = elabTestT(arg1, booleanType, env)
val (t2, env2) = elabTest(arg2, env1)
(subtype.join(List(t2, falseType)), env2)
case "orelse" =>
val env1 = elabTestT(arg1, booleanType, env)
val (t2, env2) = elabTest(arg2, env1)
(subtype.join(List(t2, trueType)), env2)
case _ =>
// $COVERAGE-OFF$
throw new IllegalStateException(s"unexpected $op")
Expand Down
18 changes: 9 additions & 9 deletions eqwalizer/test_projects/_cli/checkable_funs.cli
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all funs:
All : 2772
Checkable : 2511
Well-typed checkable : 1614
All : 2773
Checkable : 2512
Well-typed checkable : 1615
Checkable ratio : 91%
Health ratio of checkable : 64%
error count : 896
Expand All @@ -26,18 +26,18 @@ generated non-test funs:

--------------------------------------------
non-generated funs:
All : 2772
Checkable : 2511
Well-typed checkable : 1614
All : 2773
Checkable : 2512
Well-typed checkable : 1615
Checkable ratio : 91%
Health ratio of checkable : 64%
error count : 896

--------------------------------------------
non-generated non-test funs (most important):
All : 2770
Checkable : 2509
Well-typed checkable : 1613
All : 2771
Checkable : 2510
Well-typed checkable : 1614
Checkable ratio : 91%
Health ratio of checkable : 64%
error count : 895
Expand Down
4 changes: 2 additions & 2 deletions eqwalizer/test_projects/_cli/discarded_specs.cli
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ type_aliases:uses_trans_unbound_var/2
type_aliases:uses_ty_w_unbound_var/2
type_aliases:uses_ty_w_unbound_var2/0
Discarded specs: 49
Total specs: 2649
Discarded ratio: 1.8498 %
Total specs: 2650
Discarded ratio: 1.8491 %
3 changes: 2 additions & 1 deletion eqwalizer/test_projects/_cli/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,8 @@
"use_invalid_opaque_1/1",
"use_invalid_opaque_2/1",
"f/1",
"g/1"
"g/1",
"fuzz01/0"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions eqwalizer/test_projects/_cli/numbers.cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all specs:
containing number: 13.28%
containing integer: 10.48%
containing number: 13.27%
containing integer: 10.47%
containing pos_integer: 3.33%
containing non_neg_integer: 2.04%
containing neg_integer: 1.51%
Expand All @@ -21,8 +21,8 @@ generated specs:
containing range: 0.00%
containing int lit: 0.00%
non-generated specs:
containing number: 13.28%
containing integer: 10.48%
containing number: 13.27%
containing integer: 10.47%
containing pos_integer: 3.33%
containing non_neg_integer: 2.04%
containing neg_integer: 1.51%
Expand Down
4 changes: 4 additions & 0 deletions eqwalizer/test_projects/check_gradual/src/gradual_misc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ f(#{(#{} =/= a) := _}) ->
-spec g(map()) -> ok.
g(#{(a #{ b => c }) := _}) ->
ok.

-spec fuzz01() -> ok.
fuzz01() when #{(true andalso false) => {}} ->
ok.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ f(#{(#{} =/= a) := _}) -> | OK |
| |
-spec g(map()) -> ok. | |
g(#{(a #{ b => c }) := _}) -> | OK |
ok. | |
| |
-spec fuzz01() -> ok. | |
fuzz01() when #{(true andalso false) => {}…… OK |
ok. | |

0 comments on commit d8afa8e

Please sign in to comment.