| 1 |
use wasm_bindgen::prelude::*; |
| 2 |
use wasm_bindgen_test::*; |
| 3 |
|
| 4 |
#[wasm_bindgen(module = "tests/wasm/validate_prt.js")] |
| 5 |
extern "C" { |
| 6 |
fn js_works(); |
| 7 |
} |
| 8 |
|
| 9 |
#[wasm_bindgen] |
| 10 |
pub struct Fruit { |
| 11 |
name: String, |
| 12 |
} |
| 13 |
|
| 14 |
#[wasm_bindgen] |
| 15 |
impl Fruit { |
| 16 |
pub fn name(&self) -> String { |
| 17 |
self.name.clone() |
| 18 |
} |
| 19 |
|
| 20 |
#[wasm_bindgen(constructor)] |
| 21 |
pub fn new(name: String) -> Self { |
| 22 |
Fruit { name } |
| 23 |
} |
| 24 |
|
| 25 |
pub fn rot(self) { |
| 26 |
drop(self); |
| 27 |
} |
| 28 |
|
| 29 |
#[wasm_bindgen(getter)] |
| 30 |
pub fn prop(self) -> u32 { |
| 31 |
0 |
| 32 |
} |
| 33 |
|
| 34 |
#[wasm_bindgen(setter)] |
| 35 |
pub fn set_prop(self, _val: u32) {} |
| 36 |
} |
| 37 |
|
| 38 |
#[wasm_bindgen] |
| 39 |
pub fn eat(_: Fruit) {} |
| 40 |
|
| 41 |
#[wasm_bindgen_test] |
| 42 |
fn works() { |
| 43 |
js_works(); |
| 44 |
} |