Merge pull request #720 from kraai/patch-1

Test for and add extends attributes
This commit is contained in:
Alex Crichton 2018-08-18 22:15:30 -07:00 committed by GitHub
commit 9c6225fd80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 35 additions and 8 deletions

View File

@ -2093,7 +2093,7 @@ extern {
/// or range of allowed values.
///
/// 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)]
pub type RangeError;
@ -2112,7 +2112,7 @@ extern {
/// variable is referenced.
///
/// 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)]
pub type ReferenceError;
@ -2506,7 +2506,7 @@ extern {
/// parsing code.
///
/// 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)]
pub type SyntaxError;
@ -2526,7 +2526,7 @@ extern {
/// expected type.
///
/// 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)]
pub type TypeError;
@ -2759,7 +2759,7 @@ extern {
/// function was used in a wrong way.
///
/// 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)]
pub type UriError;

View File

@ -306,4 +306,5 @@ fn array_inheritance() {
let array = Array::new();
assert!(array.is_instance_of::<Array>());
assert!(array.is_instance_of::<Object>());
let _: &Object = array.as_ref();
}

View File

@ -41,4 +41,5 @@ fn arraybuffer_inheritance() {
let buf = ArrayBuffer::new(4);
assert!(buf.is_instance_of::<ArrayBuffer>());
assert!(buf.is_instance_of::<Object>());
let _: &Object = buf.as_ref();
}

View File

@ -18,4 +18,5 @@ fn boolean_inheritance() {
let b = Boolean::new(&JsValue::from(true));
assert!(b.is_instance_of::<Boolean>());
assert!(b.is_instance_of::<Object>());
let _: &Object = b.as_ref();
}

View File

@ -1,7 +1,7 @@
use js_sys::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
use wasm_bindgen::JsCast;
use js_sys::*;
#[wasm_bindgen_test]
fn test() {
@ -36,7 +36,9 @@ fn test() {
v.set_int8(0, 42);
// 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]
@ -50,4 +52,5 @@ fn dataview_inheritance() {
assert!(v.is_instance_of::<DataView>());
assert!(v.is_instance_of::<Object>());
let _: &Object = v.as_ref();
}

View File

@ -413,4 +413,5 @@ fn date_inheritance() {
let date = Date::new(&"August 19, 1975 23:15:30".into());
assert!(date.is_instance_of::<Date>());
assert!(date.is_instance_of::<Object>());
let _: &Object = date.as_ref();
}

View File

@ -42,4 +42,5 @@ fn error_inheritance() {
let error = Error::new("test");
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Object = error.as_ref();
}

View File

@ -52,4 +52,6 @@ fn evalerror_inheritance() {
assert!(error.is_instance_of::<EvalError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
}

View File

@ -66,4 +66,5 @@ fn to_string() {
fn function_inheritance() {
assert!(MAX.is_instance_of::<Function>());
assert!(MAX.is_instance_of::<Object>());
let _: &Object = MAX.as_ref();
}

View File

@ -93,4 +93,5 @@ fn map_inheritance() {
let map = Map::new();
assert!(map.is_instance_of::<Map>());
assert!(map.is_instance_of::<Object>());
let _: &Object = map.as_ref();
}

View File

@ -111,4 +111,5 @@ fn number_inheritance() {
let n = Number::new(&JsValue::from(42));
assert!(n.is_instance_of::<Number>());
assert!(n.is_instance_of::<Object>());
let _: &Object = n.as_ref();
}

View File

@ -9,6 +9,8 @@ fn range_error() {
assert!(error.is_instance_of::<RangeError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "out of range yo");

View File

@ -9,6 +9,8 @@ fn reference_error() {
assert!(error.is_instance_of::<ReferenceError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "bad reference, fool");

View File

@ -7,6 +7,7 @@ fn regexp_inheritance() {
let re = RegExp::new(".", "");
assert!(re.is_instance_of::<RegExp>());
assert!(re.is_instance_of::<Object>());
let _: &Object = re.as_ref();
}
#[wasm_bindgen_test]

View File

@ -87,4 +87,5 @@ fn set_inheritance() {
let set = Set::new(&JsValue::undefined());
assert!(set.is_instance_of::<Set>());
assert!(set.is_instance_of::<Object>());
let _: &Object = set.as_ref();
}

View File

@ -9,6 +9,8 @@ fn syntax_error() {
assert!(error.is_instance_of::<SyntaxError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");

View File

@ -9,6 +9,8 @@ fn type_error() {
assert!(error.is_instance_of::<TypeError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");

View File

@ -9,6 +9,8 @@ fn uri_error() {
assert!(error.is_instance_of::<UriError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");

View File

@ -57,4 +57,5 @@ fn weakmap_inheritance() {
let map = WeakMap::new();
assert!(map.is_instance_of::<WeakMap>());
assert!(map.is_instance_of::<Object>());
let _: &Object = map.as_ref();
}

View File

@ -47,4 +47,5 @@ fn weakset_inheritance() {
let set = WeakSet::new();
assert!(set.is_instance_of::<WeakSet>());
assert!(set.is_instance_of::<Object>());
let _: &Object = set.as_ref();
}