mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
Add acosh to Math
This commit is contained in:
parent
230650055c
commit
d40a314a91
@ -250,6 +250,14 @@ extern {
|
|||||||
#[wasm_bindgen(static_method_of = Math)]
|
#[wasm_bindgen(static_method_of = Math)]
|
||||||
pub fn acos(adjacent: i32, hypotenuse: i32) -> Number;
|
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.
|
// Number.
|
||||||
|
@ -55,3 +55,30 @@ fn acos() {
|
|||||||
"#)
|
"#)
|
||||||
.test()
|
.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()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user