Skip to content

Commit

Permalink
Stop recalculating statics in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Oct 13, 2024
1 parent 0669d9c commit c27642b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/Test_Statics.re
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@ let id_at = x => x |> List.nth(ids);
let statics = Statics.mk(CoreSettings.on, Builtins.ctx_init);
let alco_check = Alcotest.option(testable_typ) |> Alcotest.check;

let info_of_id = (f: UExp.t, id: Id.t) => {
let s = statics(f);
let info_of_id = (~statics_map=?, f: UExp.t, id: Id.t) => {
let s =
switch (statics_map) {
| Some(s) => s
| None => statics(f)
};
switch (Id.Map.find(id, s)) {
| InfoExp(ie) => Some(ie)
| _ => None
};
};

// Get the type from the statics
let type_of = f => {
Option.map((ie: Info.exp) => ie.ty, info_of_id(f, IdTagged.rep_id(f)));
let type_of = (~statics_map=?, f) => {
Option.map(
(ie: Info.exp) => ie.ty,
info_of_id(~statics_map?, f, IdTagged.rep_id(f)),
);
};

let fully_consistent_typecheck = (name, serialized, expected, exp) => {
Expand All @@ -65,7 +72,7 @@ let fully_consistent_typecheck = (name, serialized, expected, exp) => {
Statics.Map.error_ids(s),
);
Alcotest.check(list(status_exp), "Static Errors", [], errors);
alco_check(serialized, expected, type_of(exp));
alco_check(serialized, expected, type_of(~statics_map=s, exp));
},
);
};
Expand Down

0 comments on commit c27642b

Please sign in to comment.