1 module Test
= Integration_test_base
2 open Integration_test_base_types
4 let foo_fun = {|<?hh
// strict
5 function foo
(): void
{}
8 let bar_class = {|<?hh
// strict
12 let baz_typedef = {|<?hh
// strict
16 let qux_const = {|<?hh
// strict
20 let test_contents = {|<?hh
// strict
21 function test
(Baz $x
): void
{
31 "baz.php", baz_typedef;
35 let () = Tempfile.with_real_tempdir
@@ fun temp_dir
->
36 let saved_state_dir = Path.to_string temp_dir
in
37 Test.save_state
disk_state saved_state_dir;
38 let env = Test.load_state
43 ~predeclare_ide_deps
:true
46 (* After loading from saved state, nothing should be in memory *)
47 assert (not
@@ Decl_heap.Funs.mem
"\\foo");
48 assert (not
@@ Decl_heap.Classes.mem
"\\Bar");
49 assert (not
@@ Decl_heap.Typedefs.mem
"\\Baz");
50 assert (not
@@ Decl_heap.GConsts.mem
"\\QUX");
52 (* Executing any command that will lead to running type inference on test_contents *)
53 let env = Test.connect_persistent_client
env in
54 let env, _
= Test.(run_loop_once
env { default_loop_input
with
55 persistent_client_request
= Some
(
56 Request
ServerCommandTypes.(IDENTIFY_FUNCTION
((FileContent
test_contents), 5, 5))
60 (* Ensure that any results we'll get are from shared memory *)
61 SharedMem.invalidate_caches
();
63 let foo_path = Relative_path.from_root
"foo.php" in
65 (* Check that we didn't pollute parser heaps with anything *)
66 assert ((File_provider.get
foo_path) = None
);
67 assert (not
@@ Ast_provider.has_for_test
foo_path);
69 (* Check that we did populate declaration heaps *)
70 assert (Decl_heap.Funs.mem
"\\foo");
71 assert (Decl_heap.Classes.mem
"\\Bar");
72 assert (Decl_heap.Typedefs.mem
"\\Baz");
73 assert (Decl_heap.GConsts.mem
"\\QUX");