Skip to content

Commit d40a314

Browse files
committed
Add acosh to Math
1 parent 2306500 commit d40a314

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/js.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ extern {
250250
#[wasm_bindgen(static_method_of = Math)]
251251
pub fn acos(adjacent: i32, hypotenuse: i32) -> Number;
252252

253+
/// The Math.acosh() function returns the hyperbolic arc-cosine of a
254+
/// number, that is ∀x ≥ 1
255+
/// Math.acosh(x) = arcosh(x) = the unique y ≥ 0 such that cosh(y) = x
256+
///
257+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh
258+
#[wasm_bindgen(static_method_of = Math)]
259+
pub fn acosh(number: i32) -> Number;
260+
253261
}
254262

255263
// Number.

tests/all/js_globals/Math.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,30 @@ fn acos() {
5555
"#)
5656
.test()
5757
}
58+
59+
#[test]
60+
fn acosh() {
61+
project()
62+
.file("src/lib.rs", r#"
63+
#![feature(proc_macro, wasm_custom_section)]
64+
65+
extern crate wasm_bindgen;
66+
use wasm_bindgen::prelude::*;
67+
use wasm_bindgen::js;
68+
69+
#[wasm_bindgen]
70+
pub fn acosh(number: i32) -> js::Number {
71+
js::Math::acosh(number)
72+
}
73+
"#)
74+
.file("test.ts", r#"
75+
import * as assert from "assert";
76+
import * as wasm from "./out";
77+
78+
export function test() {
79+
assert.equal(wasm.acosh(1), 0);
80+
assert.equal(wasm.acosh(2), Math.acosh(2));
81+
}
82+
"#)
83+
.test()
84+
}

0 commit comments

Comments
 (0)