2018-04-10 01:32:06 +03:00
|
|
|
use super::project;
|
2018-03-23 03:37:27 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn works() {
|
2018-04-10 01:32:06 +03:00
|
|
|
project()
|
2018-06-28 08:42:34 +03:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2018-03-15 00:33:53 +03:00
|
|
|
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
2018-03-23 03:37:27 +03:00
|
|
|
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);
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.ts",
|
|
|
|
r#"
|
2018-03-23 03:37:27 +03:00
|
|
|
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);
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-03-23 03:37:27 +03:00
|
|
|
.test();
|
|
|
|
}
|