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.
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Object)]
#[derive(Clone, Debug)]
pub type Number;

View File

@ -1,9 +1,17 @@
use std::f64::{INFINITY, NAN};
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
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]
fn is_finite() {
assert!(Number::is_finite(&42.into()));