From 4e32b5e430d52a3d30d0a0975bb3280e3044794e Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 15 Mar 2019 14:27:18 -0600 Subject: [PATCH] add read_optional_enum_attribute to webidl-tests/enums --- crates/webidl-tests/enums.js | 8 ++++++++ crates/webidl-tests/enums.rs | 14 ++++++++++++++ crates/webidl-tests/enums.webidl | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/crates/webidl-tests/enums.js b/crates/webidl-tests/enums.js index fa23ec818..1750f69e2 100644 --- a/crates/webidl-tests/enums.js +++ b/crates/webidl-tests/enums.js @@ -18,4 +18,12 @@ global.Shape = class Shape { getShape() { return this.kind; } + + get shapeTypeNone() { + return null; + } + + get shapeTypeSome() { + return this.kind; + } }; diff --git a/crates/webidl-tests/enums.rs b/crates/webidl-tests/enums.rs index b5e0949e7..23f258c22 100644 --- a/crates/webidl-tests/enums.rs +++ b/crates/webidl-tests/enums.rs @@ -35,3 +35,17 @@ fn invalid_enum_return() { _ => {} // Success }; } + +#[wasm_bindgen_test] +fn read_optional_enum_attribute_none() { + let shape = Shape::new(ShapeType::Circle).unwrap(); + let shape_type: Option = shape.shape_type_none(); + assert_eq!(shape_type, None); +} + +#[wasm_bindgen_test] +fn read_optional_enum_attribute_some() { + let shape = Shape::new(ShapeType::Circle).unwrap(); + let shape_type: Option = shape.shape_type_some(); + assert_eq!(shape_type, Some(ShapeType::Circle)); +} diff --git a/crates/webidl-tests/enums.webidl b/crates/webidl-tests/enums.webidl index acd043b31..b200888d3 100644 --- a/crates/webidl-tests/enums.webidl +++ b/crates/webidl-tests/enums.webidl @@ -12,4 +12,8 @@ interface Shape { [Pure] ShapeType getShape(); + + readonly attribute ShapeType? shapeTypeNone; + + readonly attribute ShapeType? shapeTypeSome; };