@@ -49,6 +49,8 @@ describe("linking", ({test, testSkip}) => {
4949 );
5050
5151 let tuple_equal = ((a1, a2), (b1, b2)) => a1 == b1 && a2 == b2;
52+ let triple_equal = ((a1, a2, a3), (b1, b2, b3)) =>
53+ a1 == b1 && a2 == b2 && a3 == b3;
5254 test("no_start_section" , ({expect}) => {
5355 let name = "no_start_section" ;
5456 let outfile = wasmfile(name);
@@ -119,4 +121,31 @@ describe("linking", ({test, testSkip}) => {
119121 (WasmFunction , "_start" ),
120122 );
121123 });
124+
125+ test("import_memory" , ({expect}) => {
126+ let name = "import_memory" ;
127+ let outfile = wasmfile(name);
128+ ignore @@
129+ compile(
130+ ~config_fn= () => {Grain_utils . Config . import_memory := true },
131+ name,
132+ {| module Test; print("Hello, world!")|} ,
133+ );
134+ let ic = open_in_bin(outfile);
135+ let sections = Grain_utils . Wasm_utils . get_wasm_sections(ic);
136+ close_in(ic);
137+ let imports =
138+ List . find_map(
139+ (sec: Grain_utils . Wasm_utils . wasm_bin_section ) =>
140+ switch (sec) {
141+ | {sec_type: Import (imports )} => Some (imports)
142+ | _ => None
143+ },
144+ sections,
145+ );
146+ expect. list(Option . get(imports)).toContainEqual(
147+ ~equals= triple_equal,
148+ (WasmMemory , "env" , "memory" ),
149+ );
150+ });
122151});
0 commit comments