Skip to content

Commit a40b27d

Browse files
authored
Merge pull request #941 from alexcrichton/fix-201
Add tests for internal imports now working
2 parents e3e5c0f + b868185 commit a40b27d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/wasm/imports.js

+3
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ exports.assert_dead_import_not_generated = function() {
101101
const bindings = fs.readFileSync(filename);
102102
assert.ok(!bindings.includes("unused_import"));
103103
};
104+
105+
exports.import_inside_function_works = function() {};
106+
exports.import_inside_private_module = function() {};

tests/wasm/imports.rs

+28
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,31 @@ fn rename_static_with_string() {
175175
fn dead_imports_not_generated() {
176176
assert_dead_import_not_generated();
177177
}
178+
179+
#[wasm_bindgen_test]
180+
#[cfg(feature = "nightly")]
181+
fn import_inside_function_works() {
182+
#[wasm_bindgen(module = "tests/wasm/imports.js")]
183+
extern {
184+
fn import_inside_function_works();
185+
}
186+
import_inside_function_works();
187+
}
188+
189+
#[wasm_bindgen_test]
190+
#[cfg(feature = "nightly")]
191+
fn private_module_imports_work() {
192+
private::foo();
193+
}
194+
195+
mod private {
196+
use wasm_bindgen::prelude::*;
197+
198+
pub fn foo() {
199+
#[wasm_bindgen(module = "tests/wasm/imports.js")]
200+
extern {
201+
fn import_inside_private_module();
202+
}
203+
import_inside_private_module();
204+
}
205+
}

0 commit comments

Comments
 (0)