Skip to content

Commit ce73a69

Browse files
committed
Suggested test changes.
1 parent 78f6cc2 commit ce73a69

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

tests/backend/zero_alloc_checker/test_inference.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ let[@zero_alloc] f_call_var x = M_alloc_var.f_alloc2 x
2020

2121

2222
(* Arity: The typing tests show that if we just give this function the signature
23-
[val[@zero_alloc] f_arity_two : int -> int -> int] we'll get a type error.
23+
[val[@zero_alloc] f_arity_one : int -> int -> int] we'll get a type error.
2424
Here we show that if we give it a signature that passes the typechecker (the
25-
mli has [val[@zero_alloc (arity 1)] f_arity_two : int -> int -> int]), it
25+
mli has [val[@zero_alloc (arity 1)] f_arity_one : int -> int -> int]), it
2626
correctly gets checked and gives a zero_alloc backend error. *)
27-
let f_arity_two x = fun y -> x + y
27+
let f_arity_one x = fun y -> x + y
2828

2929

3030
(* Shadowing: the mli marks [f_shadow] zero_alloc. That check should only apply
@@ -34,6 +34,12 @@ let f_shadow x = (x, x+1)
3434

3535
let f_shadow _x = (42, 43) (* doesn't allocate because this is static. *)
3636

37+
(* Shadowing: the other way. This time the function exposed in the signature
38+
does allocate, and we should get an error for it. *)
39+
let f_shadow_alloc _x = (42, 43)
40+
41+
let f_shadow_alloc x = (x, x)
42+
3743
(* And now the boring part - just a test that we check each function below with
3844
the exact parameters implied by the signature (opt, strict). *)
3945

tests/backend/zero_alloc_checker/test_inference.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ module M_alloc_var : sig
66
end
77
val f_call_var : 'a -> 'a * 'a
88

9-
val[@zero_alloc (arity 1)] f_arity_two : int -> int -> int
9+
val[@zero_alloc (arity 1)] f_arity_one : int -> int -> int
1010

1111
val[@zero_alloc] f_shadow : int -> int * int
12+
val[@zero_alloc] f_shadow_alloc : int -> int * int
1213

1314
val[@zero_alloc] f_basic_success : int -> unit
1415
val[@zero_alloc] f_basic_fail : 'a -> 'a * 'a

0 commit comments

Comments
 (0)