Skip to content

Commit 7da4629

Browse files
committed
WIP on dunifying tests
Signed-off-by: Kakadu <[email protected]>
1 parent 0053a25 commit 7da4629

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

regression/expressions/gen.ml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(* let () =
2+
3+
let lamas = List.filter (String.ends_with ~suffix:".lama") (Sys.readdir "." |> Array.to_list)
4+
|> List.sort String.compare in
5+
(* List.iter print_endline lamas; *)
6+
()
7+
*)
8+
9+
let () =
10+
for i=0 to 2 do
11+
let test = In_channel.with_open_text (Printf.sprintf "generated%05d.input" i) In_channel.input_all in
12+
let test = String.split_on_char '\n' test
13+
(* |> List.filter ((<>)"") *)
14+
in
15+
16+
Out_channel.with_open_text (Printf.sprintf "r%05d.t" i) (fun ch ->
17+
Printf.fprintf ch " $ cat > test.input <<EOF\n";
18+
List.iter (Printf.fprintf ch " > %s\n") test;
19+
Printf.fprintf ch " > EOF\n";
20+
Printf.fprintf ch " $ cat test.input\n";
21+
Printf.fprintf ch " $ ls -l\n";
22+
Printf.fprintf ch " $ LAMA=../../runtime ../../src/Driver.exe -i generated%05d.lama" i
23+
)
24+
done

tools/tool.ml

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type config =
1717
}
1818

1919
let config = { filename= "file.ml"; pos="0,0"; line=0; col=0; mode = GoToDef }
20+
let _ = if false then config.pos <- "" else ignore config.pos
2021
let parse_loc loc =
2122
Scanf.sscanf loc "%d,%d" (fun l c -> config.line <- l; config.col <- c)
2223

@@ -53,7 +54,7 @@ let do_find e =
5354
inherit [_,_] Language.Expr.foldl_t_t_stub (foldl_decl, fself) as super
5455
method! c_Var _inh _ name = on_name name _inh
5556
method! c_Ref _inh _ name = on_name name _inh
56-
method c_Scope init e names r =
57+
method! c_Scope init e names r =
5758
let map = ListLabels.fold_left ~init names ~f:(fun acc (fname,(_,info)) ->
5859
let acc = Introduced.extend fname (Loc.get_exn fname) acc in
5960
match info with
@@ -70,7 +71,7 @@ let do_find e =
7071
(* Format.printf "STUB. Ht size = %d\n%!" (Loc.H.length Loc.tab);
7172
Loc.H.iter (fun k (l,c) -> Format.printf "%s -> (%d,%d)\n%!" k l c) Loc.tab; *)
7273

73-
let (_,fold_t) = Expr.fix_decl Expr.foldl_decl_0 ooo in
74+
let (_,fold_t) = Expr.fix_decl_t Expr.foldl_decl_0 ooo in
7475
match fold_t Introduced.empty e with
7576
| exception (DefinitionFound arg) -> Some arg
7677
| _ -> None
@@ -89,29 +90,29 @@ let find_usages root (def_name,(_,_)) =
8990
if in_scope then (on_name name acc, in_scope) else (acc, in_scope)
9091
method! c_Ref (acc,in_scope) _ name =
9192
self#c_Var (acc,in_scope) (Var name) name
92-
method c_Scope init e names r =
93+
method! c_Scope init e names r =
9394
ListLabels.fold_left ~init names ~f:(fun ((acc, in_scope) as inh) (name,info) ->
9495
match (in_scope, String.equal def_name name) with
9596
| (true, true) -> (acc, false)
9697
| (true, _) -> begin
9798
match snd info with
98-
| `Fun (args, body) when List.mem def_name args -> inh
99-
| `Fun (args, body) -> fself inh body
99+
| `Fun (args, _) when List.mem def_name args -> inh
100+
| `Fun (_, body) -> fself inh body
100101
| `Variable (Some rhs) -> fself inh rhs
101102
| `Variable None -> inh
102103
end
103104
| (false, true) -> super#c_Scope (acc,true) e names r
104105
| false,false -> begin
105106
match snd info with
106107
| `Fun (args, body) when List.memq def_name args -> fself (acc,true) body
107-
| `Fun (args, body) -> fself inh body
108+
| `Fun (_, body) -> fself inh body
108109
| `Variable (Some rhs) -> fself inh rhs
109110
| `Variable None -> inh
110111
end
111112
) |> (fun acc -> fself acc r)
112113
end in
113114

114-
let (_,fold_t) = Expr.fix_decl Expr.foldl_decl_0 ooo in
115+
let (_,fold_t) = Expr.fix_decl_t Expr.foldl_decl_0 ooo in
115116
fold_t ([],false) root
116117

117118

0 commit comments

Comments
 (0)