mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 10:10:52 +00:00
Add atan2 to Math
This commit is contained in:
parent
7e514b939f
commit
3223a9af75
@ -279,6 +279,13 @@ extern {
|
||||
#[wasm_bindgen(static_method_of = Math)]
|
||||
pub fn atan(number: i32) -> Number;
|
||||
|
||||
/// The Math.atan2() function returns the arctangent of the quotient of
|
||||
/// its arguments.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2
|
||||
#[wasm_bindgen(static_method_of = Math)]
|
||||
pub fn atan2(y: i32, x: i32) -> Number;
|
||||
|
||||
}
|
||||
|
||||
// Number.
|
||||
|
@ -160,3 +160,29 @@ fn atan() {
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn atan2() {
|
||||
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 atan2(x: i32, y: i32) -> js::Number {
|
||||
js::Math::atan2(x, y)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert.equal(wasm.atan2(1, 2), Math.atan2(1, 2));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user