diff --git a/src/js.rs b/src/js.rs index 5e2cf0f3..ba11048e 100644 --- a/src/js.rs +++ b/src/js.rs @@ -273,6 +273,11 @@ extern { #[wasm_bindgen(static_method_of = Math)] pub fn asinh(number: i32) -> Number; + /// The Math.atan() function returns the arctangent (in radians) of a + /// number, that is Math.atan(x) = arctan(x) = the unique y ∊ [-π2;π2]such that + /// tan(y) = x + #[wasm_bindgen(static_method_of = Math)] + pub fn atan(number: i32) -> Number; } diff --git a/tests/all/js_globals/Math.rs b/tests/all/js_globals/Math.rs index 144c91e7..ec08dde9 100644 --- a/tests/all/js_globals/Math.rs +++ b/tests/all/js_globals/Math.rs @@ -134,3 +134,29 @@ fn asinh() { "#) .test() } + +#[test] +fn atan() { + 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 atan(number: i32) -> js::Number { + js::Math::atan(number) + } + "#) + .file("test.ts", r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + assert.equal(wasm.atan(1), Math.atan(1)); + } + "#) + .test() +}