Skip to content

Commit

Permalink
Accept tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Feb 25, 2022
1 parent d2069ab commit eb89ec9
Show file tree
Hide file tree
Showing 27 changed files with 79 additions and 79 deletions.
4 changes: 2 additions & 2 deletions testsuite/tests/backtrace/backtrace_effects.ml
Expand Up @@ -7,7 +7,7 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let bar i =
if i < 0 then begin
Expand All @@ -29,7 +29,7 @@ let baz () =
match_with foo 10
{ retc = (fun x -> ());
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun (k : (a, _) continuation) ->
print_endline "(** get_continuation_callstack **)";
Expand Down
8 changes: 4 additions & 4 deletions testsuite/tests/backtrace/backtrace_effects_nested.ml
Expand Up @@ -13,8 +13,8 @@ reference = "${test_source_directory}/backtrace_effects_nested.flambda.reference
open Effect
open Effect.Deep

type _ eff += E : unit eff
| Inc : unit eff
type _ t += E : unit t
| Inc : unit t

let blorp () =
perform Inc;
Expand All @@ -23,7 +23,7 @@ let blorp () =

let baz () =
try_with blorp ()
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| Inc -> Some (fun (k : (a, _) continuation) ->
1 + continue k ())
Expand All @@ -33,7 +33,7 @@ let f () =
match_with baz ()
{ retc = (fun x -> Printf.printf "%d\n" x);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun (k : (a, _) continuation) ->
Deep.get_callstack k 100 |>
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tests/callback/nested_fiber.ml
Expand Up @@ -11,7 +11,7 @@ external caml_to_c : (unit -> 'a) -> 'a = "caml_to_c"
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

type 'a tree = Empty | Node of 'a tree * 'a tree

Expand All @@ -34,7 +34,7 @@ let f () =
match_with g ()
{ retc = (fun () -> Printf.printf "g() returned: %d\n%!" !z);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun (k : (a, _) continuation) -> assert false)
| _ -> None };
Expand All @@ -46,7 +46,7 @@ let () =
match_with f ()
{ retc = (fun () -> Printf.printf "f() returned: %d\n%!" !z);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> assert false)
| _ -> None };
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/callback/stack_overflow.ml
Expand Up @@ -17,15 +17,15 @@ let rec deep = function
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let () =
Printf.printf "%d\n%d\n%!"
(!(deep 1000))
(match_with deep 1000
{ retc = (fun x -> !x);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> assert false)
| _ -> None })
4 changes: 2 additions & 2 deletions testsuite/tests/callback/test7.ml
Expand Up @@ -13,7 +13,7 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let printf = Printf.printf

Expand All @@ -36,7 +36,7 @@ let _ =
perform E)
end;
printf "[Caml] Return from caml_to_c\n%!") ()
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> printf "[Caml] Caught effect\n%!")
| _ -> None }
4 changes: 2 additions & 2 deletions testsuite/tests/effects/backtrace.ml
Expand Up @@ -22,7 +22,7 @@ let rec bar i =
end
[@@inline never]

type _ eff += Wait : unit eff
type _ t += Wait : unit t

let task1 () =
try
Expand All @@ -45,7 +45,7 @@ let main () =
exnc = (fun e ->
let open Printexc in
print_raw_backtrace stdout (get_raw_backtrace ()));
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| Wait -> Some (fun (k : (a, _) continuation) ->
discontinue_with_backtrace k x bt)
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/effects/cmphash.ml
Expand Up @@ -4,11 +4,11 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let () =
try_with perform E
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k ->
begin match k = k with
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/effects/evenodd.ml
Expand Up @@ -4,12 +4,12 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let rec even n =
if n = 0 then true
else try_with odd (n-1)
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> assert false)
| _ -> None }
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/effects/issue479.ml
Expand Up @@ -19,7 +19,7 @@ type ('a,'container) iter2gen =
-> 'container
-> 'a generator;;

type _ eff += Hold: unit eff
type _ t += Hold: unit t

let iter2gen : _ iter2gen = fun iter c ->
let r = ref None in
Expand All @@ -31,7 +31,7 @@ let iter2gen : _ iter2gen = fun iter c ->
match_with (iter suspending_f) c
{ retc = (fun _ -> fun () -> None);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| Hold -> Some (fun (k : (a,_) continuation) ->
fun () ->
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/effects/overflow.ml
Expand Up @@ -4,7 +4,7 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let f a b c d e f g h =
let bb = b + b in
Expand Down Expand Up @@ -34,7 +34,7 @@ let () =
match_with (fun _ -> f 1 2 3 4 5 6 7 8) ()
{ retc = (fun n -> Printf.printf "%d\n" n);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> assert false)
| _ -> None }
6 changes: 3 additions & 3 deletions testsuite/tests/effects/partial.ml
Expand Up @@ -4,12 +4,12 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t
exception Done

let handle_partial f =
try_with f ()
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> assert false)
| _ -> None }
Expand All @@ -22,7 +22,7 @@ let () =
exnc = (function
| Done -> print_string "ok\n"
| e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun (k : (a, _) continuation) -> discontinue k Done)
| _ -> None }
10 changes: 5 additions & 5 deletions testsuite/tests/effects/reperform.ml
Expand Up @@ -4,16 +4,16 @@
open Effect
open Effect.Deep

type _ eff += E : int -> int eff
| F : unit eff
type _ t += E : int -> int t
| F : unit t

let rec nest = function
| 0 -> perform (E 42)
| n ->
match_with (fun _ -> Printf.printf "[%d\n" n; nest (n - 1)) ()
{ retc = (fun x -> Printf.printf " %d]\n" n; x);
exnc = (fun e -> Printf.printf " !%d]\n" n; raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| F -> Some (fun k -> assert false)
| _ -> None }
Expand All @@ -22,7 +22,7 @@ let () =
match_with nest 5
{ retc = (fun x -> Printf.printf "= %d\n" x);
exnc = (fun e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| E n -> Some (fun (k : (a, _) continuation) -> continue k (n + 100))
| _ -> None }
Expand All @@ -31,7 +31,7 @@ let () =
match_with nest 5
{ retc = (fun x -> assert false);
exnc = (fun e -> Printf.printf "%s\n" (Printexc.to_string e));
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| F -> Some (fun k -> assert false)
| _ -> None }
10 changes: 5 additions & 5 deletions testsuite/tests/effects/sched.ml
Expand Up @@ -5,9 +5,9 @@ open Effect
open Effect.Deep

exception E
type _ eff += Yield : unit eff
| Fork : (unit -> string) -> unit eff
| Ping : unit eff
type _ t += Yield : unit t
| Fork : (unit -> string) -> unit t
| Ping : unit t
exception Pong

let say = print_string
Expand All @@ -27,7 +27,7 @@ let run main =
exnc = (function
| E -> say "!"; dequeue ()
| e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| Yield -> Some (fun (k : (a, _) continuation) ->
say ","; enqueue k; dequeue ())
Expand All @@ -48,7 +48,7 @@ let test () =
exnc = (function
| Pong -> say "]"
| e -> raise e);
effc = fun (type a) (e : a eff) ->
effc = fun (type a) (e : a t) ->
match e with
| Yield -> Some (fun (k : (a,_) continuation) -> failwith "what?")
| _ -> None }
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tests/effects/shallow_state.ml
Expand Up @@ -15,16 +15,16 @@ let handle_state init f x =
loop init (fiber f) x
*)

type _ eff += Get : int eff
| Set : int -> unit eff
type _ t += Get : int t
| Set : int -> unit t

let handle_state init f x =
let rec loop : type a r. int -> (a, r) continuation -> a -> r * int =
fun state k x ->
continue_with k x
{ retc = (fun result -> result, state);
exnc = (fun e -> raise e);
effc = (fun (type b) (eff : b eff) ->
effc = (fun (type b) (eff : b t) ->
match eff with
| Get -> Some (fun (k : (b,r) continuation) ->
loop state k state)
Expand Down
10 changes: 5 additions & 5 deletions testsuite/tests/effects/shallow_state_io.ml
Expand Up @@ -4,17 +4,17 @@
open Effect
open Effect.Shallow

type _ eff += Get : int eff
| Set : int -> unit eff
| Print : string -> unit eff
type _ t += Get : int t
| Set : int -> unit t
| Print : string -> unit t

let handle_state init f x =
let rec loop : type a r. int -> (a, r) continuation -> a -> r * int =
fun state k x ->
continue_with k x
{ retc = (fun result -> result, state);
exnc = (fun e -> raise e);
effc = (fun (type b) (eff : b eff) ->
effc = (fun (type b) (eff : b t) ->
match eff with
| Get -> Some (fun (k : (b,r) continuation) ->
loop state k state)
Expand All @@ -30,7 +30,7 @@ let handle_print f =
continue_with k ()
{ retc = (fun x -> x);
exnc = (fun e -> raise e);
effc = (fun (type a) (eff : a eff) ->
effc = (fun (type a) (eff : a t) ->
match eff with
| Print s -> Some (fun (k : (a,r) continuation) ->
print_string s; loop k)
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/effects/test1.ml
Expand Up @@ -4,12 +4,12 @@
open Effect
open Effect.Deep

type _ eff += E : unit eff
type _ t += E : unit t

let () =
Printf.printf "%d\n%!" @@
try_with (fun x -> x) 10
{ effc = (fun (type a) (e : a eff) ->
{ effc = (fun (type a) (e : a t) ->
match e with
| E -> Some (fun k -> 11)
| e -> None) }
8 changes: 4 additions & 4 deletions testsuite/tests/effects/test10.ml
Expand Up @@ -4,8 +4,8 @@
open Effect
open Effect.Deep

type _ eff += Peek : int eff
type _ eff += Poke : unit eff
type _ t += Peek : int t
type _ t += Poke : unit t

let rec a i = perform Peek + Random.int i
let rec b i = a i + Random.int i
Expand All @@ -14,15 +14,15 @@ let rec c i = b i + Random.int i
let rec d i =
Random.int i +
try_with c i
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| Poke -> Some (fun (k : (a,_) continuation) -> continue k ())
| _ -> None }

let rec e i =
Random.int i +
try_with d i
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| Peek -> Some (fun (k : (a,_) continuation) ->
ignore (Deep.get_callstack k 100);
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/effects/test11.ml
Expand Up @@ -7,11 +7,11 @@
open Effect
open Effect.Deep

type _ eff += E : int eff
type _ t += E : int t

let handle comp =
try_with comp ()
{ effc = fun (type a) (e : a eff) ->
{ effc = fun (type a) (e : a t) ->
match e with
| E -> Some (fun (k : (a,_) continuation) -> continue k 10)
| _ -> None }
Expand Down

0 comments on commit eb89ec9

Please sign in to comment.