mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-28 14:27:36 +03:00
Merge pull request #720 from kraai/patch-1
Test for and add extends attributes
This commit is contained in:
commit
9c6225fd80
@ -2093,7 +2093,7 @@ extern {
|
|||||||
/// or range of allowed values.
|
/// or range of allowed values.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
|
||||||
#[wasm_bindgen(extends = Error)]
|
#[wasm_bindgen(extends = Error, extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type RangeError;
|
pub type RangeError;
|
||||||
|
|
||||||
@ -2112,7 +2112,7 @@ extern {
|
|||||||
/// variable is referenced.
|
/// variable is referenced.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError
|
||||||
#[wasm_bindgen(extends = Error)]
|
#[wasm_bindgen(extends = Error, extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type ReferenceError;
|
pub type ReferenceError;
|
||||||
|
|
||||||
@ -2506,7 +2506,7 @@ extern {
|
|||||||
/// parsing code.
|
/// parsing code.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
|
||||||
#[wasm_bindgen(extends = Error)]
|
#[wasm_bindgen(extends = Error, extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type SyntaxError;
|
pub type SyntaxError;
|
||||||
|
|
||||||
@ -2526,7 +2526,7 @@ extern {
|
|||||||
/// expected type.
|
/// expected type.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
|
||||||
#[wasm_bindgen(extends = Error)]
|
#[wasm_bindgen(extends = Error, extends = Object)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type TypeError;
|
pub type TypeError;
|
||||||
|
|
||||||
@ -2759,7 +2759,7 @@ extern {
|
|||||||
/// function was used in a wrong way.
|
/// function was used in a wrong way.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
|
||||||
#[wasm_bindgen(extends = Error, js_name = URIError)]
|
#[wasm_bindgen(extends = Error, extends = Object, js_name = URIError)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub type UriError;
|
pub type UriError;
|
||||||
|
|
||||||
|
@ -306,4 +306,5 @@ fn array_inheritance() {
|
|||||||
let array = Array::new();
|
let array = Array::new();
|
||||||
assert!(array.is_instance_of::<Array>());
|
assert!(array.is_instance_of::<Array>());
|
||||||
assert!(array.is_instance_of::<Object>());
|
assert!(array.is_instance_of::<Object>());
|
||||||
|
let _: &Object = array.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -41,4 +41,5 @@ fn arraybuffer_inheritance() {
|
|||||||
let buf = ArrayBuffer::new(4);
|
let buf = ArrayBuffer::new(4);
|
||||||
assert!(buf.is_instance_of::<ArrayBuffer>());
|
assert!(buf.is_instance_of::<ArrayBuffer>());
|
||||||
assert!(buf.is_instance_of::<Object>());
|
assert!(buf.is_instance_of::<Object>());
|
||||||
|
let _: &Object = buf.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -18,4 +18,5 @@ fn boolean_inheritance() {
|
|||||||
let b = Boolean::new(&JsValue::from(true));
|
let b = Boolean::new(&JsValue::from(true));
|
||||||
assert!(b.is_instance_of::<Boolean>());
|
assert!(b.is_instance_of::<Boolean>());
|
||||||
assert!(b.is_instance_of::<Object>());
|
assert!(b.is_instance_of::<Object>());
|
||||||
|
let _: &Object = b.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
use js_sys::*;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use wasm_bindgen::JsValue;
|
use wasm_bindgen::JsValue;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use js_sys::*;
|
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn test() {
|
fn test() {
|
||||||
@ -36,7 +36,9 @@ fn test() {
|
|||||||
v.set_int8(0, 42);
|
v.set_int8(0, 42);
|
||||||
|
|
||||||
// TODO: figure out how to do `bytes[2]`
|
// TODO: figure out how to do `bytes[2]`
|
||||||
bytes.subarray(2, 3).for_each(&mut |x, _, _| assert_eq!(x, 42));
|
bytes
|
||||||
|
.subarray(2, 3)
|
||||||
|
.for_each(&mut |x, _, _| assert_eq!(x, 42));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
@ -50,4 +52,5 @@ fn dataview_inheritance() {
|
|||||||
|
|
||||||
assert!(v.is_instance_of::<DataView>());
|
assert!(v.is_instance_of::<DataView>());
|
||||||
assert!(v.is_instance_of::<Object>());
|
assert!(v.is_instance_of::<Object>());
|
||||||
|
let _: &Object = v.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -413,4 +413,5 @@ fn date_inheritance() {
|
|||||||
let date = Date::new(&"August 19, 1975 23:15:30".into());
|
let date = Date::new(&"August 19, 1975 23:15:30".into());
|
||||||
assert!(date.is_instance_of::<Date>());
|
assert!(date.is_instance_of::<Date>());
|
||||||
assert!(date.is_instance_of::<Object>());
|
assert!(date.is_instance_of::<Object>());
|
||||||
|
let _: &Object = date.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,5 @@ fn error_inheritance() {
|
|||||||
let error = Error::new("test");
|
let error = Error::new("test");
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,6 @@ fn evalerror_inheritance() {
|
|||||||
assert!(error.is_instance_of::<EvalError>());
|
assert!(error.is_instance_of::<EvalError>());
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Error = error.as_ref();
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,5 @@ fn to_string() {
|
|||||||
fn function_inheritance() {
|
fn function_inheritance() {
|
||||||
assert!(MAX.is_instance_of::<Function>());
|
assert!(MAX.is_instance_of::<Function>());
|
||||||
assert!(MAX.is_instance_of::<Object>());
|
assert!(MAX.is_instance_of::<Object>());
|
||||||
|
let _: &Object = MAX.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -93,4 +93,5 @@ fn map_inheritance() {
|
|||||||
let map = Map::new();
|
let map = Map::new();
|
||||||
assert!(map.is_instance_of::<Map>());
|
assert!(map.is_instance_of::<Map>());
|
||||||
assert!(map.is_instance_of::<Object>());
|
assert!(map.is_instance_of::<Object>());
|
||||||
|
let _: &Object = map.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -111,4 +111,5 @@ fn number_inheritance() {
|
|||||||
let n = Number::new(&JsValue::from(42));
|
let n = Number::new(&JsValue::from(42));
|
||||||
assert!(n.is_instance_of::<Number>());
|
assert!(n.is_instance_of::<Number>());
|
||||||
assert!(n.is_instance_of::<Object>());
|
assert!(n.is_instance_of::<Object>());
|
||||||
|
let _: &Object = n.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ fn range_error() {
|
|||||||
assert!(error.is_instance_of::<RangeError>());
|
assert!(error.is_instance_of::<RangeError>());
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Error = error.as_ref();
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
|
|
||||||
let base: &Error = error.as_ref();
|
let base: &Error = error.as_ref();
|
||||||
assert_eq!(JsValue::from(base.message()), "out of range yo");
|
assert_eq!(JsValue::from(base.message()), "out of range yo");
|
||||||
|
@ -9,6 +9,8 @@ fn reference_error() {
|
|||||||
assert!(error.is_instance_of::<ReferenceError>());
|
assert!(error.is_instance_of::<ReferenceError>());
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Error = error.as_ref();
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
|
|
||||||
let base: &Error = error.as_ref();
|
let base: &Error = error.as_ref();
|
||||||
assert_eq!(JsValue::from(base.message()), "bad reference, fool");
|
assert_eq!(JsValue::from(base.message()), "bad reference, fool");
|
||||||
|
@ -7,6 +7,7 @@ fn regexp_inheritance() {
|
|||||||
let re = RegExp::new(".", "");
|
let re = RegExp::new(".", "");
|
||||||
assert!(re.is_instance_of::<RegExp>());
|
assert!(re.is_instance_of::<RegExp>());
|
||||||
assert!(re.is_instance_of::<Object>());
|
assert!(re.is_instance_of::<Object>());
|
||||||
|
let _: &Object = re.as_ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
|
@ -87,4 +87,5 @@ fn set_inheritance() {
|
|||||||
let set = Set::new(&JsValue::undefined());
|
let set = Set::new(&JsValue::undefined());
|
||||||
assert!(set.is_instance_of::<Set>());
|
assert!(set.is_instance_of::<Set>());
|
||||||
assert!(set.is_instance_of::<Object>());
|
assert!(set.is_instance_of::<Object>());
|
||||||
|
let _: &Object = set.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ fn syntax_error() {
|
|||||||
assert!(error.is_instance_of::<SyntaxError>());
|
assert!(error.is_instance_of::<SyntaxError>());
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Error = error.as_ref();
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
|
|
||||||
let base: &Error = error.as_ref();
|
let base: &Error = error.as_ref();
|
||||||
assert_eq!(JsValue::from(base.message()), "msg");
|
assert_eq!(JsValue::from(base.message()), "msg");
|
||||||
|
@ -9,6 +9,8 @@ fn type_error() {
|
|||||||
assert!(error.is_instance_of::<TypeError>());
|
assert!(error.is_instance_of::<TypeError>());
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Error = error.as_ref();
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
|
|
||||||
let base: &Error = error.as_ref();
|
let base: &Error = error.as_ref();
|
||||||
assert_eq!(JsValue::from(base.message()), "msg");
|
assert_eq!(JsValue::from(base.message()), "msg");
|
||||||
|
@ -9,6 +9,8 @@ fn uri_error() {
|
|||||||
assert!(error.is_instance_of::<UriError>());
|
assert!(error.is_instance_of::<UriError>());
|
||||||
assert!(error.is_instance_of::<Error>());
|
assert!(error.is_instance_of::<Error>());
|
||||||
assert!(error.is_instance_of::<Object>());
|
assert!(error.is_instance_of::<Object>());
|
||||||
|
let _: &Error = error.as_ref();
|
||||||
|
let _: &Object = error.as_ref();
|
||||||
|
|
||||||
let base: &Error = error.as_ref();
|
let base: &Error = error.as_ref();
|
||||||
assert_eq!(JsValue::from(base.message()), "msg");
|
assert_eq!(JsValue::from(base.message()), "msg");
|
||||||
|
@ -57,4 +57,5 @@ fn weakmap_inheritance() {
|
|||||||
let map = WeakMap::new();
|
let map = WeakMap::new();
|
||||||
assert!(map.is_instance_of::<WeakMap>());
|
assert!(map.is_instance_of::<WeakMap>());
|
||||||
assert!(map.is_instance_of::<Object>());
|
assert!(map.is_instance_of::<Object>());
|
||||||
|
let _: &Object = map.as_ref();
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,5 @@ fn weakset_inheritance() {
|
|||||||
let set = WeakSet::new();
|
let set = WeakSet::new();
|
||||||
assert!(set.is_instance_of::<WeakSet>());
|
assert!(set.is_instance_of::<WeakSet>());
|
||||||
assert!(set.is_instance_of::<Object>());
|
assert!(set.is_instance_of::<Object>());
|
||||||
|
let _: &Object = set.as_ref();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user