Merge pull request #941 from alexcrichton/fix-201

Add tests for internal imports now working
This commit is contained in:
Alex Crichton 2018-10-08 10:20:05 -07:00 committed by GitHub
commit a40b27da60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
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() {
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();
}
}