File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,15 @@ extern {
241
241
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs
242
242
#[ wasm_bindgen( static_method_of = Math ) ]
243
243
pub fn abs ( number : i32 ) -> Number ;
244
+
245
+ /// The Math.acos() function returns the arccosine (in radians) of a
246
+ /// number, that is ∀x∊[-1;1]
247
+ /// Math.acos(x) = arccos(x) = the unique y∊[0;π] such that cos(y)=x
248
+ ///
249
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos
250
+ #[ wasm_bindgen( static_method_of = Math ) ]
251
+ pub fn acos ( adjacent : i32 , hypotenuse : i32 ) -> Number ;
252
+
244
253
}
245
254
246
255
// Number.
Original file line number Diff line number Diff line change @@ -24,7 +24,33 @@ fn abs() {
24
24
25
25
export function test() {
26
26
assert.equal(wasm.abs(-32), Math.abs(-32));
27
- assert.equal(wasm.abs(32), 32));
27
+ assert.equal(wasm.abs(32), 32);
28
+ }
29
+ "# )
30
+ . test ( )
31
+ }
32
+
33
+ #[ test]
34
+ fn acos ( ) {
35
+ project ( )
36
+ . file ( "src/lib.rs" , r#"
37
+ #![feature(proc_macro, wasm_custom_section)]
38
+
39
+ extern crate wasm_bindgen;
40
+ use wasm_bindgen::prelude::*;
41
+ use wasm_bindgen::js;
42
+
43
+ #[wasm_bindgen]
44
+ pub fn acos(adjacent: i32, hypotenuse: i32) -> js::Number {
45
+ js::Math::acos(adjacent, hypotenuse)
46
+ }
47
+ "# )
48
+ . file ( "test.ts" , r#"
49
+ import * as assert from "assert";
50
+ import * as wasm from "./out";
51
+
52
+ export function test() {
53
+ assert.equal(wasm.acos(-1, 1), Math.PI);
28
54
}
29
55
"# )
30
56
. test ( )
You can’t perform that action at this time.
0 commit comments