js-sys: Add extends to Math

Part of #670
This commit is contained in:
Nick Fitzgerald 2018-09-06 13:39:30 -07:00
parent 5df2347a7a
commit bfff8661c1
2 changed files with 14 additions and 0 deletions

View File

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

View File

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