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
This commit is contained in:
Alex Crichton 2018-10-08 09:47:17 -07:00
parent e3e5c0f57d
commit b868185637
2 changed files with 31 additions and 0 deletions

View File

@ -101,3 +101,6 @@ exports.assert_dead_import_not_generated = function() {
const bindings = fs.readFileSync(filename); const bindings = fs.readFileSync(filename);
assert.ok(!bindings.includes("unused_import")); assert.ok(!bindings.includes("unused_import"));
}; };
exports.import_inside_function_works = function() {};
exports.import_inside_private_module = function() {};

View File

@ -175,3 +175,31 @@ fn rename_static_with_string() {
fn dead_imports_not_generated() { fn dead_imports_not_generated() {
assert_dead_import_not_generated(); assert_dead_import_not_generated();
} }
#[wasm_bindgen_test]
#[cfg(feature = "nightly")]
fn import_inside_function_works() {
#[wasm_bindgen(module = "tests/wasm/imports.js")]
extern {
fn import_inside_function_works();
}
import_inside_function_works();
}
#[wasm_bindgen_test]
#[cfg(feature = "nightly")]
fn private_module_imports_work() {
private::foo();
}
mod private {
use wasm_bindgen::prelude::*;
pub fn foo() {
#[wasm_bindgen(module = "tests/wasm/imports.js")]
extern {
fn import_inside_private_module();
}
import_inside_private_module();
}
}