mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-14 16:36:07 +00:00
Add asin to Math
This commit is contained in:
parent
d40a314a91
commit
94255c1ba9
@ -258,6 +258,14 @@ extern {
|
|||||||
#[wasm_bindgen(static_method_of = Math)]
|
#[wasm_bindgen(static_method_of = Math)]
|
||||||
pub fn acosh(number: i32) -> Number;
|
pub fn acosh(number: i32) -> Number;
|
||||||
|
|
||||||
|
/// The Math.asin() function returns the arcsine (in radians) of a
|
||||||
|
/// number, that is ∀x ∊ [-1;1]
|
||||||
|
/// Math.asin(x) = arcsin(x) = the unique y∊[-π2;π2] such that sin(y) = x
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin
|
||||||
|
#[wasm_bindgen(static_method_of = Math)]
|
||||||
|
pub fn asin(number: i32) -> Number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number.
|
// Number.
|
||||||
|
@ -82,3 +82,29 @@ fn acosh() {
|
|||||||
"#)
|
"#)
|
||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn asin() {
|
||||||
|
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 asin(opposite: i32, hypotenuse: i32) -> js::Number {
|
||||||
|
js::Math::asin(opposite / hypotenuse)
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.file("test.ts", r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
assert.equal(wasm.asin(1, 1), Math.asin(1));
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user