1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-03-16 18:20:51 +00:00

Add acosh to Math

This commit is contained in:
Jonathan Sundqvist 2018-06-25 21:54:24 +02:00
parent 230650055c
commit d40a314a91
2 changed files with 35 additions and 0 deletions
src
tests/all/js_globals

@ -250,6 +250,14 @@ extern {
#[wasm_bindgen(static_method_of = Math)]
pub fn acos(adjacent: i32, hypotenuse: i32) -> Number;
/// The Math.acosh() function returns the hyperbolic arc-cosine of a
/// number, that is ∀x ≥ 1
/// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh
#[wasm_bindgen(static_method_of = Math)]
pub fn acosh(number: i32) -> Number;
}
// Number.

@ -55,3 +55,30 @@ fn acos() {
"#)
.test()
}
#[test]
fn acosh() {
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 acosh(number: i32) -> js::Number {
js::Math::acosh(number)
}
"#)
.file("test.ts", r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.acosh(1), 0);
assert.equal(wasm.acosh(2), Math.acosh(2));
}
"#)
.test()
}