From f0811d5ac0becd7cb325c59e8d8d849805a31e7a Mon Sep 17 00:00:00 2001 From: Mason Stallmo Date: Sun, 19 Aug 2018 10:03:56 -0500 Subject: [PATCH 1/5] Add extends to js-sys:Intl.Collater --- crates/js-sys/src/lib.rs | 2 +- crates/js-sys/tests/wasm/Intl.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 487fc095..8b4e2854 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -3401,7 +3401,7 @@ pub mod Intl { /// that enable language sensitive string comparison. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator - #[wasm_bindgen(js_namespace = Intl)] + #[wasm_bindgen(extends = Object, js_namespace = Intl)] #[derive(Clone, Debug)] pub type Collator; diff --git a/crates/js-sys/tests/wasm/Intl.rs b/crates/js-sys/tests/wasm/Intl.rs index 6fc8add6..a22b75e4 100644 --- a/crates/js-sys/tests/wasm/Intl.rs +++ b/crates/js-sys/tests/wasm/Intl.rs @@ -35,6 +35,10 @@ fn collator() { let a = Intl::Collator::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); + + assert!(c.is_instance_of::()); + assert!(c.is_instance_of::()); + let _: &Object = c.as_ref(); } #[wasm_bindgen_test] From 780c7236f1de7196f6ab630e05afd6b499b6b087 Mon Sep 17 00:00:00 2001 From: Mason Stallmo Date: Sun, 19 Aug 2018 10:13:25 -0500 Subject: [PATCH 2/5] Add extends to js-sys:Intl.DateTimeFormat --- crates/js-sys/src/lib.rs | 2 +- crates/js-sys/tests/wasm/Intl.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 8b4e2854..89169596 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -3445,7 +3445,7 @@ pub mod Intl { /// that enable language-sensitive date and time formatting. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat - #[wasm_bindgen(js_namespace = Intl)] + #[wasm_bindgen(extends = Object, js_namespace = Intl)] #[derive(Clone, Debug)] pub type DateTimeFormat; diff --git a/crates/js-sys/tests/wasm/Intl.rs b/crates/js-sys/tests/wasm/Intl.rs index a22b75e4..62f6102f 100644 --- a/crates/js-sys/tests/wasm/Intl.rs +++ b/crates/js-sys/tests/wasm/Intl.rs @@ -54,6 +54,10 @@ fn date_time_format() { let a = Intl::DateTimeFormat::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); + + assert!(c.is_instance_of::()); + assert!(c.is_instance_of::()); + let _: &Object = c.as_ref(); } #[wasm_bindgen_test] From ee131888da9eb62b8cd416641c1e1e14793b0ebe Mon Sep 17 00:00:00 2001 From: Mason Stallmo Date: Sun, 19 Aug 2018 10:19:03 -0500 Subject: [PATCH 3/5] Add extends to js-sys:Intl.NumberFormat --- crates/js-sys/src/lib.rs | 2 +- crates/js-sys/tests/wasm/Intl.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 89169596..e402b6ab 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -3496,7 +3496,7 @@ pub mod Intl { /// that enable language sensitive number formatting. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat - #[wasm_bindgen(js_namespace = Intl)] + #[wasm_bindgen(extends = Object, js_namespace = Intl)] #[derive(Clone, Debug)] pub type NumberFormat; diff --git a/crates/js-sys/tests/wasm/Intl.rs b/crates/js-sys/tests/wasm/Intl.rs index 62f6102f..8abff50b 100644 --- a/crates/js-sys/tests/wasm/Intl.rs +++ b/crates/js-sys/tests/wasm/Intl.rs @@ -72,6 +72,10 @@ fn number_format() { let a = Intl::NumberFormat::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); + + assert!(n.is_instance_of::()); + assert!(n.is_instance_of::()); + let _: &Object = n.as_ref(); } #[wasm_bindgen_test] From 1762b3cba007fa5d2b4c389154d8ec7a97334a3d Mon Sep 17 00:00:00 2001 From: Mason Stallmo Date: Sun, 19 Aug 2018 11:03:55 -0500 Subject: [PATCH 4/5] Add extends to js-sys:Intl.PluralRules --- crates/js-sys/src/lib.rs | 2 +- crates/js-sys/tests/wasm/Intl.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index e402b6ab..e429d413 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -3546,7 +3546,7 @@ pub mod Intl { /// that enable plural sensitive formatting and plural language rules. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules - #[wasm_bindgen(js_namespace = Intl)] + #[wasm_bindgen(extends = Object, js_namespace = Intl)] #[derive(Clone, Debug)] pub type PluralRules; diff --git a/crates/js-sys/tests/wasm/Intl.rs b/crates/js-sys/tests/wasm/Intl.rs index 8abff50b..4fd43f5d 100644 --- a/crates/js-sys/tests/wasm/Intl.rs +++ b/crates/js-sys/tests/wasm/Intl.rs @@ -87,6 +87,10 @@ fn plural_rules() { assert!(r.resolved_options().is_instance_of::()); assert_eq!(r.select(1_f64), "one"); - let r = Intl::PluralRules::supported_locales_of(&locales, &opts); - assert!(r.is_instance_of::()); + let a = Intl::PluralRules::supported_locales_of(&locales, &opts); + assert!(a.is_instance_of::()); + + assert!(r.is_instance_of::()); + assert!(r.is_instance_of::()); + let _: &Object = r.as_ref(); } From b330bd1bf1065d826e86b219503afff6b74a84e3 Mon Sep 17 00:00:00 2001 From: Mason Stallmo Date: Sun, 19 Aug 2018 11:27:04 -0500 Subject: [PATCH 5/5] Refactor inheritance checks into their own tests --- crates/js-sys/tests/wasm/Intl.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/js-sys/tests/wasm/Intl.rs b/crates/js-sys/tests/wasm/Intl.rs index 4fd43f5d..74c57ecd 100644 --- a/crates/js-sys/tests/wasm/Intl.rs +++ b/crates/js-sys/tests/wasm/Intl.rs @@ -35,6 +35,13 @@ fn collator() { let a = Intl::Collator::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); +} + +#[wasm_bindgen_test] +fn collator_inheritance() { + let locales = Array::of1(&JsValue::from("en-US")); + let opts = Object::new(); + let c = Intl::Collator::new(&locales, &opts); assert!(c.is_instance_of::()); assert!(c.is_instance_of::()); @@ -54,6 +61,13 @@ fn date_time_format() { let a = Intl::DateTimeFormat::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); +} + +#[wasm_bindgen_test] +fn date_time_format_inheritance() { + let locales = Array::of1(&JsValue::from("en-US")); + let opts = Object::new(); + let c = Intl::DateTimeFormat::new(&locales, &opts); assert!(c.is_instance_of::()); assert!(c.is_instance_of::()); @@ -72,6 +86,13 @@ fn number_format() { let a = Intl::NumberFormat::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); +} + +#[wasm_bindgen_test] +fn number_format_inheritance() { + let locales = Array::of1(&JsValue::from("en-US")); + let opts = Object::new(); + let n = Intl::NumberFormat::new(&locales, &opts); assert!(n.is_instance_of::()); assert!(n.is_instance_of::()); @@ -89,6 +110,13 @@ fn plural_rules() { let a = Intl::PluralRules::supported_locales_of(&locales, &opts); assert!(a.is_instance_of::()); +} + +#[wasm_bindgen_test] +fn plural_rules_inheritance() { + let locales = Array::of1(&JsValue::from("en-US")); + let opts = Object::new(); + let r = Intl::PluralRules::new(&locales, &opts); assert!(r.is_instance_of::()); assert!(r.is_instance_of::());