| 1 |
use wasm_bindgen::prelude::*; |
| 2 |
use wasm_bindgen_test::*; |
| 3 |
|
| 4 |
#[wasm_bindgen(module = "tests/wasm/structural.js")] |
| 5 |
extern "C" { |
| 6 |
fn js_works(); |
| 7 |
} |
| 8 |
|
| 9 |
#[wasm_bindgen] |
| 10 |
extern "C" { |
| 11 |
pub type StructuralFoo; |
| 12 |
|
| 13 |
#[wasm_bindgen(method, structural)] |
| 14 |
fn bar(this: &StructuralFoo); |
| 15 |
#[wasm_bindgen(method, getter, structural)] |
| 16 |
fn baz(this: &StructuralFoo) -> u32; |
| 17 |
#[wasm_bindgen(method, setter, structural)] |
| 18 |
fn set_baz(this: &StructuralFoo, val: u32); |
| 19 |
} |
| 20 |
|
| 21 |
#[wasm_bindgen] |
| 22 |
pub fn run(a: &StructuralFoo) { |
| 23 |
a.bar(); |
| 24 |
assert_eq!(a.baz(), 1); |
| 25 |
a.set_baz(2); |
| 26 |
assert_eq!(a.baz(), 2); |
| 27 |
} |
| 28 |
|
| 29 |
#[wasm_bindgen_test] |
| 30 |
fn works() { |
| 31 |
js_works(); |
| 32 |
} |