Skip to content

Commit b868185

Browse files
committed
Add tests for internal imports now working
These compiler bugs have now been fixed on nightly, so we just need to wait for the bug fixes to ride the trains to be available to everyone! Closes #201
1 parent e3e5c0f commit b868185

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/wasm/imports.js

Lines changed: 3 additions & 0 deletions
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

Lines changed: 28 additions & 0 deletions
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)