Skip to content

Commit

Permalink
js-sys: Add extends to Math
Browse files Browse the repository at this point in the history
Part of rustwasm#670
  • Loading branch information
fitzgen committed Sep 6, 2018
1 parent 5df2347 commit bfff866
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/js-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ extern {
#[wasm_bindgen]
extern "C" {
#[derive(Clone, Debug)]
#[wasm_bindgen(extends = Object)]
pub type Math;

/// The Math.abs() function returns the absolute value of a number, that is
Expand Down
13 changes: 13 additions & 0 deletions crates/js-sys/tests/wasm/Math.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
use std::f64::consts::PI;
use std::f64::{NEG_INFINITY, NAN};

use wasm_bindgen::{JsCast, prelude::*};
use wasm_bindgen_test::*;
use js_sys::*;

#[wasm_bindgen_test]
fn math_extends() {
#[wasm_bindgen]
extern {
#[wasm_bindgen(js_name = Math)]
static math: Math;
}

assert!(math.is_instance_of::<Object>());
let _: &Object = math.as_ref();
}

macro_rules! assert_eq {
($a:expr, $b:expr) => ({
let (a, b) = (&$a, &$b);
Expand Down

0 comments on commit bfff866

Please sign in to comment.