wasm-bindgen/tests/wasm/structural.rs
Alex Crichton 7ecf4aae87 cargo +nightly fmt --all
Rustfmt all the things!
2018-09-26 08:26:00 -07:00

33 lines
605 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 Foo;
#[wasm_bindgen(method, structural)]
fn bar(this: &Foo);
#[wasm_bindgen(method, getter, structural)]
fn baz(this: &Foo) -> u32;
#[wasm_bindgen(method, setter, structural)]
fn set_baz(this: &Foo, val: u32);
}
#[wasm_bindgen]
pub fn run(a: &Foo) {
a.bar();
assert_eq!(a.baz(), 1);
a.set_baz(2);
assert_eq!(a.baz(), 2);
}
#[wasm_bindgen_test]
fn works() {
js_works();
}