mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-24 21:52:13 +00:00
exhausively match JSImportName (#2090)
This commit is contained in:
parent
4900732f60
commit
3c40492fa3
@ -2097,7 +2097,19 @@ impl<'a> Context<'a> {
|
||||
fn prestore_global_import_identifiers(&mut self) -> Result<(), Error> {
|
||||
for import in self.aux.import_map.values() {
|
||||
let js = match import {
|
||||
AuxImport::Value(AuxValue::Bare(js)) => js,
|
||||
AuxImport::Value(AuxValue::Bare(js))
|
||||
| AuxImport::Value(AuxValue::ClassGetter(js, ..))
|
||||
| AuxImport::Value(AuxValue::Getter(js, ..))
|
||||
| AuxImport::Value(AuxValue::ClassSetter(js, ..))
|
||||
| AuxImport::Value(AuxValue::Setter(js, ..))
|
||||
| AuxImport::ValueWithThis(js, ..)
|
||||
| AuxImport::Instanceof(js)
|
||||
| AuxImport::Static(js)
|
||||
| AuxImport::StructuralClassGetter(js, ..)
|
||||
| AuxImport::StructuralClassSetter(js, ..)
|
||||
| AuxImport::IndexingGetterOfClass(js)
|
||||
| AuxImport::IndexingSetterOfClass(js)
|
||||
| AuxImport::IndexingDeleterOfClass(js) => js,
|
||||
_ => continue,
|
||||
};
|
||||
if let JsImportName::Global { .. } = js.name {
|
||||
|
@ -132,6 +132,10 @@ exports.Math = {
|
||||
func_from_module_math: (a) => a * 2
|
||||
}
|
||||
|
||||
exports.Number = {
|
||||
func_from_module_number: () => 3.0
|
||||
}
|
||||
|
||||
exports.same_name_from_import = (a) => a * 3;
|
||||
|
||||
exports.same_js_namespace_from_module = {
|
||||
|
@ -73,6 +73,9 @@ extern "C" {
|
||||
#[wasm_bindgen(js_namespace = Math)]
|
||||
fn func_from_module_math(a: i32) -> i32;
|
||||
|
||||
#[wasm_bindgen(js_namespace = Number)]
|
||||
fn func_from_module_number() -> f64;
|
||||
|
||||
#[wasm_bindgen(js_name = "same_name_from_import")]
|
||||
fn same_name_from_import_1(s: i32) -> i32;
|
||||
|
||||
@ -95,6 +98,10 @@ extern "C" {
|
||||
|
||||
#[wasm_bindgen(js_namespace = Math, js_name = "sqrt")]
|
||||
fn func_from_global_math(s: f64) -> f64;
|
||||
|
||||
type Number;
|
||||
#[wasm_bindgen(getter, static_method_of = Number, js_name = "NAN")]
|
||||
fn static_getter_from_global_number() -> f64;
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
@ -301,7 +308,11 @@ fn func_from_global_and_module_same_js_namespace() {
|
||||
assert_eq!(func_from_global_math(4.0), 2.0);
|
||||
assert_eq!(func_from_module_math(2), 4);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn getter_from_global_and_module_same_name() {
|
||||
assert!(Number::static_getter_from_global_number().is_nan());
|
||||
assert_eq!(func_from_module_number(), 3.0);
|
||||
}
|
||||
#[wasm_bindgen_test]
|
||||
fn func_from_two_modules_same_js_name() {
|
||||
assert_eq!(same_name_from_import_1(1), 3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user