Merge pull request #730 from mstallmo/add-extends-to-js-sys

Add extends to js sys Intl.Collater, Intl.DateTimeFormat, Intl.NumberFormat, and Intl.PluralRules
This commit is contained in:
Alex Crichton 2018-08-19 10:28:31 -07:00 committed by GitHub
commit 12a6aaa1bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 6 deletions

View File

@ -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;
@ -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;
@ -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;
@ -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;

View File

@ -37,6 +37,17 @@ fn collator() {
assert!(a.is_instance_of::<Array>());
}
#[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::<Intl::Collator>());
assert!(c.is_instance_of::<Object>());
let _: &Object = c.as_ref();
}
#[wasm_bindgen_test]
fn date_time_format() {
let locales = Array::of1(&JsValue::from("en-US"));
@ -52,6 +63,17 @@ fn date_time_format() {
assert!(a.is_instance_of::<Array>());
}
#[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::<Intl::DateTimeFormat>());
assert!(c.is_instance_of::<Object>());
let _: &Object = c.as_ref();
}
#[wasm_bindgen_test]
fn number_format() {
let locales = Array::of1(&JsValue::from("en-US"));
@ -66,6 +88,17 @@ fn number_format() {
assert!(a.is_instance_of::<Array>());
}
#[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::<Intl::NumberFormat>());
assert!(n.is_instance_of::<Object>());
let _: &Object = n.as_ref();
}
#[wasm_bindgen_test]
fn plural_rules() {
let locales = Array::of1(&JsValue::from("en-US"));
@ -75,6 +108,17 @@ fn plural_rules() {
assert!(r.resolved_options().is_instance_of::<Object>());
assert_eq!(r.select(1_f64), "one");
let r = Intl::PluralRules::supported_locales_of(&locales, &opts);
assert!(r.is_instance_of::<Array>());
let a = Intl::PluralRules::supported_locales_of(&locales, &opts);
assert!(a.is_instance_of::<Array>());
}
#[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::<Intl::PluralRules>());
assert!(r.is_instance_of::<Object>());
let _: &Object = r.as_ref();
}