mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-28 14:27:36 +03:00
6aacff6a80
Remove a bunch of exception throws in favor of type casts in TypeScript and remove some type assertions as well that TypeScript should uphold.
43 lines
1.0 KiB
Rust
43 lines
1.0 KiB
Rust
extern crate test_support;
|
|
|
|
#[test]
|
|
fn works() {
|
|
test_support::project()
|
|
.debug(false)
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro)]
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
wasm_bindgen! {
|
|
pub struct A {}
|
|
|
|
impl A {
|
|
pub fn new() -> A {
|
|
A {}
|
|
}
|
|
}
|
|
pub fn clone(a: &JsObject) -> JsObject {
|
|
drop(a.clone());
|
|
a.clone()
|
|
}
|
|
}
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import * as assert from "assert";
|
|
import { Exports, Imports } from "./out";
|
|
|
|
export const imports: Imports = {};
|
|
|
|
export function test(wasm: Exports) {
|
|
let sym = Symbol('a');
|
|
assert.strictEqual(wasm.clone(sym), sym);
|
|
let a = wasm.A.new();
|
|
a.free();
|
|
}
|
|
"#)
|
|
.test();
|
|
}
|