blob: 7d51673a557084456150ea653b8198ab3f912792 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
#[wasm_bindgen]
pub struct OwnedValue {
pub n: f64,
}
#[wasm_bindgen]
impl OwnedValue {
#[wasm_bindgen(constructor)]
pub fn new(n: f64) -> Self {
Self { n }
}
pub fn add(self, other: OwnedValue) -> Self {
Self {
n: self.n + other.n,
}
}
pub fn n(self) -> f64 {
self.n
}
}
#[wasm_bindgen(module = "tests/wasm/owned.js")]
extern "C" {
fn create_garbage();
}
#[wasm_bindgen_test]
fn test_create_garbage() {
create_garbage()
}
|