diff options
author | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-05-12 18:09:56 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-05-12 20:39:31 +0200 |
commit | f893a2eaacee70b1044cea88dd184cd05dda31fa (patch) | |
tree | 368ba2c1c7f6d3187edda940b3ba4f7b3b8a6c0f /components/script/dom/testbinding.rs | |
parent | 203898c941e4ac2c3a3a2f247ea3924c60858633 (diff) | |
download | servo-f893a2eaacee70b1044cea88dd184cd05dda31fa.tar.gz servo-f893a2eaacee70b1044cea88dd184cd05dda31fa.zip |
bindings: Add test for keywords in dictionaries
Diffstat (limited to 'components/script/dom/testbinding.rs')
-rw-r--r-- | components/script/dom/testbinding.rs | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index f8b45599b18..e7d4d1a9cff 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -6,7 +6,9 @@ use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use dom::bindings::codegen::Bindings::FunctionBinding::Function; -use dom::bindings::codegen::Bindings::TestBindingBinding::{self, TestBindingMethods, TestEnum}; +use dom::bindings::codegen::Bindings::TestBindingBinding; +use dom::bindings::codegen::Bindings::TestBindingBinding::{TestBindingMethods, TestDictionary}; +use dom::bindings::codegen::Bindings::TestBindingBinding::{TestDictionaryDefaults, TestEnum}; use dom::bindings::codegen::UnionTypes::{BlobOrBoolean, BlobOrBlobSequence}; use dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString}; use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong}; @@ -286,6 +288,71 @@ impl TestBindingMethods for TestBinding { Some(UnsignedLongOrBoolean::UnsignedLong(0u32)) } fn ReceiveNullableSequence(&self) -> Option<Vec<i32>> { Some(vec![1]) } + fn ReceiveTestDictionaryWithSuccessOnKeyword(&self) -> TestDictionary { + TestDictionary { + anyValue: NullValue(), + booleanValue: None, + byteValue: None, + dict: TestDictionaryDefaults { + UnrestrictedDoubleValue: 0.0, + anyValue: NullValue(), + booleanValue: false, + byteValue: 0, + doubleValue: Finite::new(1.0).unwrap(), + enumValue: TestEnum::Foo, + floatValue: Finite::new(1.0).unwrap(), + longLongValue: 54, + longValue: 12, + nullableBooleanValue: None, + nullableByteValue: None, + nullableDoubleValue: None, + nullableFloatValue: None, + nullableLongLongValue: None, + nullableLongValue: None, + nullableObjectValue: ptr::null_mut(), + nullableOctetValue: None, + nullableShortValue: None, + nullableStringValue: None, + nullableUnrestrictedDoubleValue: None, + nullableUnrestrictedFloatValue: None, + nullableUnsignedLongLongValue: None, + nullableUnsignedLongValue: None, + nullableUnsignedShortValue: None, + nullableUsvstringValue: None, + octetValue: 0, + shortValue: 0, + stringValue: DOMString::new(), + unrestrictedFloatValue: 0.0, + unsignedLongLongValue: 0, + unsignedLongValue: 0, + unsignedShortValue: 0, + usvstringValue: USVString("".to_owned()), + }, + doubleValue: None, + enumValue: None, + floatValue: None, + interfaceValue: None, + longLongValue: None, + longValue: None, + objectValue: None, + octetValue: None, + requiredValue: true, + seqDict: None, + shortValue: None, + stringValue: None, + type_: Some(DOMString::from("success")), + unrestrictedDoubleValue: None, + unrestrictedFloatValue: None, + unsignedLongLongValue: None, + unsignedLongValue: None, + unsignedShortValue: None, + usvstringValue: None, + } + } + + fn TypeKeywordIsSuccess(&self, arg: &TestDictionary) -> bool { + arg.type_.as_ref().map(|s| s == "success").unwrap_or(false) + } fn PassBoolean(&self, _: bool) {} fn PassByte(&self, _: i8) {} |