2018-04-10 01:32:06 +03:00
|
|
|
use super::project;
|
2018-02-18 03:43:58 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn auto_bind_math() {
|
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)]
|
2018-02-18 03:43:58 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-03-06 01:25:15 +03:00
|
|
|
pub fn math(a: f32, b: f64) -> f64 {
|
2018-02-18 03:43:58 +03:00
|
|
|
b.acos() +
|
|
|
|
b.asin() +
|
|
|
|
b.atan() +
|
|
|
|
b.atan2(b) +
|
|
|
|
b.cbrt() +
|
|
|
|
b.cosh() +
|
|
|
|
b.exp_m1() +
|
|
|
|
b.ln_1p() +
|
|
|
|
b.sinh() +
|
|
|
|
b.tan() +
|
|
|
|
b.tanh() +
|
|
|
|
b.hypot(b) +
|
|
|
|
b.cos() +
|
|
|
|
b.exp() +
|
|
|
|
b.exp2() +
|
|
|
|
b.mul_add(b, b) +
|
2018-03-20 00:23:39 +03:00
|
|
|
b.ln() +
|
2018-02-18 03:43:58 +03:00
|
|
|
b.log(b) +
|
|
|
|
b.log10() +
|
|
|
|
b.log2() +
|
|
|
|
b.powi(8) +
|
|
|
|
b.powf(b) +
|
|
|
|
b.round() +
|
|
|
|
b.sin() +
|
2018-03-20 00:23:39 +03:00
|
|
|
b.abs() +
|
|
|
|
b.signum() +
|
|
|
|
b.floor() +
|
|
|
|
b.ceil() +
|
|
|
|
b.trunc() +
|
|
|
|
b.sqrt() +
|
2018-02-18 03:43:58 +03:00
|
|
|
(b % (a as f64)) +
|
|
|
|
((a.cos() +
|
|
|
|
a.exp() +
|
|
|
|
a.exp2() +
|
|
|
|
a.mul_add(a, a) +
|
2018-03-20 00:23:39 +03:00
|
|
|
a.ln() +
|
2018-02-18 03:43:58 +03:00
|
|
|
a.log(a) +
|
|
|
|
a.log10() +
|
|
|
|
a.log2() +
|
|
|
|
a.powi(8) +
|
|
|
|
a.powf(a) +
|
|
|
|
a.round() +
|
|
|
|
a.sin() +
|
2018-03-20 00:23:39 +03:00
|
|
|
a.abs() +
|
|
|
|
a.signum() +
|
|
|
|
a.floor() +
|
|
|
|
a.ceil() +
|
|
|
|
a.trunc() +
|
|
|
|
a.sqrt() +
|
2018-02-18 03:43:58 +03:00
|
|
|
(a % (b as f32))) as f64) +
|
|
|
|
(b + 2.0f64.powf(a as f64))
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.ts",
|
|
|
|
r#"
|
2018-02-18 03:43:58 +03:00
|
|
|
import { math } from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
math(1.0, 2.0);
|
|
|
|
}
|
2018-06-28 08:42:34 +03:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-18 03:43:58 +03:00
|
|
|
.test();
|
|
|
|
}
|