mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-11 06:36:05 +00:00
add read_optional_enum_attribute to webidl-tests/enums
This commit is contained in:
parent
1014bdb5df
commit
4e32b5e430
@ -18,4 +18,12 @@ global.Shape = class Shape {
|
|||||||
getShape() {
|
getShape() {
|
||||||
return this.kind;
|
return this.kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get shapeTypeNone() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
get shapeTypeSome() {
|
||||||
|
return this.kind;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -35,3 +35,17 @@ fn invalid_enum_return() {
|
|||||||
_ => {} // Success
|
_ => {} // Success
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn read_optional_enum_attribute_none() {
|
||||||
|
let shape = Shape::new(ShapeType::Circle).unwrap();
|
||||||
|
let shape_type: Option<ShapeType> = 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<ShapeType> = shape.shape_type_some();
|
||||||
|
assert_eq!(shape_type, Some(ShapeType::Circle));
|
||||||
|
}
|
||||||
|
4
crates/webidl-tests/enums.webidl
vendored
4
crates/webidl-tests/enums.webidl
vendored
@ -12,4 +12,8 @@ interface Shape {
|
|||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
ShapeType getShape();
|
ShapeType getShape();
|
||||||
|
|
||||||
|
readonly attribute ShapeType? shapeTypeNone;
|
||||||
|
|
||||||
|
readonly attribute ShapeType? shapeTypeSome;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user