mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 04:51:23 +00:00
Implement Math.min() and Math.max() bindings (#542)
* Add Number.isNaN() binding * Add binding for Math.hypot() * Implement Math.min() and Math.max() bindings
This commit is contained in:
committed by
Alex Crichton
parent
f437e06463
commit
cefe1681ab
@ -172,6 +172,24 @@ fn log2() {
|
||||
assert_eq!(Math::log2(0.), NEG_INFINITY);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn max() {
|
||||
assert_eq!(Math::max(3., 1.), 3.);
|
||||
assert_eq!(Math::max(-3., 1.), 1.);
|
||||
assert_eq!(Math::max(9913., 43.4), 9913.);
|
||||
assert_eq!(Math::max(-27., -43.), -27.);
|
||||
assert_eq!(Math::max(-423.27, -43.1), -43.1);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn min() {
|
||||
assert_eq!(Math::min(3., 1.), 1.);
|
||||
assert_eq!(Math::min(-3., 1.), -3.);
|
||||
assert_eq!(Math::min(9913., 43.4), 43.4);
|
||||
assert_eq!(Math::min(-27., -43.), -43.);
|
||||
assert_eq!(Math::min(-423.27, -43.1), -423.27);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn pow() {
|
||||
assert_eq!(Math::pow(7., 2.), 49.);
|
||||
|
Reference in New Issue
Block a user