mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-01 23:04:36 +03:00
656d69816d
Nowadays the compile times are mitigated with incremental compilation and otherwise it's much more ergonomic to run only one test if they're all in the same suite.
49 lines
1.2 KiB
Rust
49 lines
1.2 KiB
Rust
use super::project;
|
|
|
|
#[test]
|
|
fn works() {
|
|
project()
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
extern {
|
|
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);
|
|
}
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import * as assert from "assert";
|
|
import { run } from "./out";
|
|
|
|
export function test() {
|
|
let called = false;
|
|
run({
|
|
bar() { called = true; },
|
|
baz: 1,
|
|
});
|
|
assert.strictEqual(called, true);
|
|
}
|
|
"#)
|
|
.test();
|
|
}
|
|
|
|
|