Add atan to Math

This commit is contained in:
Jonathan Sundqvist 2018-06-25 22:23:58 +02:00
parent 4b812ee47d
commit 7e514b939f
2 changed files with 31 additions and 0 deletions

View File

@ -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;
}

View File

@ -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()
}