Merge pull request #1356 from c410-f3r/ts-tests

Improve TS tests
This commit is contained in:
Alex Crichton 2019-03-18 10:10:21 -05:00 committed by GitHub
commit ae47665b4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 63 additions and 32 deletions

View File

@ -1,11 +0,0 @@
import * as wbg from './pkg/typescript_tests';
import * as wasm from './pkg/typescript_tests_bg';
const a1: (a: string) => void = wbg.greet;
const a2: (a: number, b: number) => void = wasm.greet;
const a3: WebAssembly.Memory = wasm.memory;
const c = new wbg.A();
wbg.A.other();
c.foo();
c.free();

View File

@ -0,0 +1,11 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen(typescript_custom_section)]
const TS_INTERFACE_EXPORT: &'static str = r"
interface Height { height: number; }
";
#[wasm_bindgen]
pub struct Person {
pub height: u32,
}

View File

@ -0,0 +1,3 @@
import * as wbg from '../pkg/typescript_tests';
const height: wbg.Height = new wbg.Person();

View File

@ -1,20 +1,4 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn greet(_: &str) {}
#[wasm_bindgen]
struct A {
}
#[wasm_bindgen]
impl A {
#[wasm_bindgen(constructor)]
pub fn new() -> A {
A {}
}
pub fn other() {}
pub fn foo(&self) {}
}
mod custom_section;
mod opt_args_and_ret;
mod simple_fn;
mod simple_struct;

View File

@ -0,0 +1,3 @@
import * as wasm from '../pkg/typescript_tests_bg';
const memory: WebAssembly.Memory = wasm.memory;

View File

@ -0,0 +1,6 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn opt_fn(_a: Option<i32>) -> Option<i32> {
None
}

View File

@ -0,0 +1,3 @@
import * as wbg from '../pkg/typescript_tests';
const opt_fn: (a: number | undefined) => number | undefined = wbg.opt_fn;

View File

@ -0,0 +1,4 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn greet(_: &str) {}

View File

@ -0,0 +1,5 @@
import * as wbg from '../pkg/typescript_tests';
import * as wasm from '../pkg/typescript_tests_bg';
const wbg_greet: (a: string) => void = wbg.greet;
const wasm_greet: (a: number, b: number) => void = wasm.greet;

View File

@ -0,0 +1,17 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct A {
}
#[wasm_bindgen]
impl A {
#[wasm_bindgen(constructor)]
pub fn new() -> A {
A {}
}
pub fn other() {}
pub fn foo(&self) {}
}

View File

@ -0,0 +1,6 @@
import * as wbg from '../pkg/typescript_tests';
const a = new wbg.A();
wbg.A.other();
a.foo();
a.free();

View File

@ -9,6 +9,6 @@
"baseUrl": "."
},
"include": [
"index.ts"
"src/*.ts"
]
}