Skip to content

Commit 7e514b9

Browse files
committed
Add atan to Math
1 parent 4b812ee commit 7e514b9

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/js.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ extern {
273273
#[wasm_bindgen(static_method_of = Math)]
274274
pub fn asinh(number: i32) -> Number;
275275

276+
/// The Math.atan() function returns the arctangent (in radians) of a
277+
/// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that
278+
/// tan(y) = x
279+
#[wasm_bindgen(static_method_of = Math)]
280+
pub fn atan(number: i32) -> Number;
276281

277282
}
278283

tests/all/js_globals/Math.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,29 @@ fn asinh() {
134134
"#)
135135
.test()
136136
}
137+
138+
#[test]
139+
fn atan() {
140+
project()
141+
.file("src/lib.rs", r#"
142+
#![feature(proc_macro, wasm_custom_section)]
143+
144+
extern crate wasm_bindgen;
145+
use wasm_bindgen::prelude::*;
146+
use wasm_bindgen::js;
147+
148+
#[wasm_bindgen]
149+
pub fn atan(number: i32) -> js::Number {
150+
js::Math::atan(number)
151+
}
152+
"#)
153+
.file("test.ts", r#"
154+
import * as assert from "assert";
155+
import * as wasm from "./out";
156+
157+
export function test() {
158+
assert.equal(wasm.atan(1), Math.atan(1));
159+
}
160+
"#)
161+
.test()
162+
}

0 commit comments

Comments
 (0)