mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-28 12:32:37 +03:00
js-sys: Add bindings to RangeError
This commit is contained in:
parent
adad606ee3
commit
879fd43edb
@ -2084,6 +2084,25 @@ extern {
|
|||||||
pub fn revocable(target: &JsValue, handler: &Object) -> Object;
|
pub fn revocable(target: &JsValue, handler: &Object) -> Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RangeError
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern {
|
||||||
|
/// The RangeError object indicates an error when a value is not in the set
|
||||||
|
/// or range of allowed values.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
|
||||||
|
#[wasm_bindgen(extends = Error)]
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub type RangeError;
|
||||||
|
|
||||||
|
/// The RangeError object indicates an error when a value is not in the set
|
||||||
|
/// or range of allowed values.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
|
||||||
|
#[wasm_bindgen(constructor)]
|
||||||
|
pub fn new(message: &str) -> RangeError;
|
||||||
|
}
|
||||||
|
|
||||||
// Reflect
|
// Reflect
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
14
crates/js-sys/tests/wasm/RangeError.rs
Normal file
14
crates/js-sys/tests/wasm/RangeError.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
use wasm_bindgen::JsValue;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
use js_sys::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn range_error() {
|
||||||
|
let error = RangeError::new("out of range yo");
|
||||||
|
assert!(error.is_instance_of::<RangeError>());
|
||||||
|
assert!(error.is_instance_of::<Error>());
|
||||||
|
|
||||||
|
let base: &Error = error.as_ref();
|
||||||
|
assert_eq!(JsValue::from(base.message()), "out of range yo");
|
||||||
|
}
|
@ -25,6 +25,7 @@ pub mod Math;
|
|||||||
pub mod Number;
|
pub mod Number;
|
||||||
pub mod Object;
|
pub mod Object;
|
||||||
pub mod Proxy;
|
pub mod Proxy;
|
||||||
|
pub mod RangeError;
|
||||||
pub mod Reflect;
|
pub mod Reflect;
|
||||||
pub mod RegExp;
|
pub mod RegExp;
|
||||||
pub mod Set;
|
pub mod Set;
|
||||||
|
Loading…
Reference in New Issue
Block a user