From 4b812ee47de7dc8586c466047e0a12537d006b51 Mon Sep 17 00:00:00 2001 From: Jonathan Sundqvist Date: Mon, 25 Jun 2018 22:23:24 +0200 Subject: [PATCH] Add asinh to Math --- src/js.rs | 8 ++++++++ tests/all/js_globals/Math.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/js.rs b/src/js.rs index 9832a66e..5e2cf0f3 100644 --- a/src/js.rs +++ b/src/js.rs @@ -266,6 +266,14 @@ extern { #[wasm_bindgen(static_method_of = Math)] pub fn asin(number: i32) -> Number; + /// The Math.asinh() function returns the hyperbolic arcsine of a + /// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x + /// + /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh + #[wasm_bindgen(static_method_of = Math)] + pub fn asinh(number: i32) -> Number; + + } // Number. diff --git a/tests/all/js_globals/Math.rs b/tests/all/js_globals/Math.rs index 7aeca2f5..144c91e7 100644 --- a/tests/all/js_globals/Math.rs +++ b/tests/all/js_globals/Math.rs @@ -108,3 +108,29 @@ fn asin() { "#) .test() } + +#[test] +fn asinh() { + project() + .file("src/lib.rs", r#" + #![feature(proc_macro, wasm_custom_section)] + + extern crate wasm_bindgen; + use wasm_bindgen::prelude::*; + use wasm_bindgen::js; + + #[wasm_bindgen] + pub fn asinh(number: i32) -> js::Number { + js::Math::asinh(number) + } + "#) + .file("test.ts", r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + assert.equal(wasm.asinh(1), Math.asinh(1)); + } + "#) + .test() +}