wasm-bindgen/tests/wasm/structural.rs
Alex Crichton 3d43d6e5e8 Fix importing and exporting the same name
Run exports through the same identifier generation as imports to ensure
that everything gets a unique identifier and then just make sure all the
appropriate wires are hooked up when dealing with exports and imports.

Closes #1496
2019-05-03 07:15:20 -07:00

33 lines
655 B
Rust

use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
#[wasm_bindgen(module = "tests/wasm/structural.js")]
extern "C" {
fn js_works();
}
#[wasm_bindgen]
extern "C" {
pub type StructuralFoo;
#[wasm_bindgen(method, structural)]
fn bar(this: &StructuralFoo);
#[wasm_bindgen(method, getter, structural)]
fn baz(this: &StructuralFoo) -> u32;
#[wasm_bindgen(method, setter, structural)]
fn set_baz(this: &StructuralFoo, val: u32);
}
#[wasm_bindgen]
pub fn run(a: &StructuralFoo) {
a.bar();
assert_eq!(a.baz(), 1);
a.set_baz(2);
assert_eq!(a.baz(), 2);
}
#[wasm_bindgen_test]
fn works() {
js_works();
}