js-sys: Add extends attributes for js_sys::Number

This commit is contained in:
bokuweb 2018-08-09 08:56:59 +09:00
parent 16dbed59b2
commit 42e02f7769
2 changed files with 9 additions and 0 deletions

View File

@ -1385,6 +1385,7 @@ extern "C" {
// Number. // Number.
#[wasm_bindgen] #[wasm_bindgen]
extern "C" { extern "C" {
#[wasm_bindgen(extends = Object)]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub type Number; pub type Number;

View File

@ -1,9 +1,17 @@
use std::f64::{INFINITY, NAN}; use std::f64::{INFINITY, NAN};
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue; use wasm_bindgen::JsValue;
use wasm_bindgen_test::*; use wasm_bindgen_test::*;
use js_sys::*; use js_sys::*;
#[wasm_bindgen_test]
fn number_inheritance() {
let number = Number::new(&JsValue::from(10));
assert!(number.is_instance_of::<Number>());
assert!(number.is_instance_of::<Object>());
}
#[wasm_bindgen_test] #[wasm_bindgen_test]
fn is_finite() { fn is_finite() {
assert!(Number::is_finite(&42.into())); assert!(Number::is_finite(&42.into()));