From 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:41:41 +0200 Subject: Merging upstream version 1.70.0+dfsg2. Signed-off-by: Daniel Baumann --- vendor/wasm-bindgen/tests/wasm/option.rs | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 vendor/wasm-bindgen/tests/wasm/option.rs (limited to 'vendor/wasm-bindgen/tests/wasm/option.rs') diff --git a/vendor/wasm-bindgen/tests/wasm/option.rs b/vendor/wasm-bindgen/tests/wasm/option.rs new file mode 100644 index 000000000..4b4cc4379 --- /dev/null +++ b/vendor/wasm-bindgen/tests/wasm/option.rs @@ -0,0 +1,61 @@ +use wasm_bindgen::prelude::*; +use wasm_bindgen_test::*; + +#[wasm_bindgen(module = "tests/wasm/option.js")] +extern "C" { + pub type MyType; + #[wasm_bindgen(constructor)] + fn new() -> MyType; + + fn take_none_byval(t: Option); + fn take_some_byval(t: Option); + fn return_undef_byval() -> Option; + fn return_null_byval() -> Option; + fn return_some_byval() -> Option; + fn test_option_values(); + + #[wasm_bindgen(js_name = take_none_byval)] + fn take_none_byref(t: Option<&MyType>); + #[wasm_bindgen(js_name = take_some_byval)] + fn take_some_byref(t: Option<&MyType>); +} + +#[wasm_bindgen_test] +fn import_by_value() { + take_none_byval(None); + take_some_byval(Some(MyType::new())); + assert!(return_null_byval().is_none()); + assert!(return_undef_byval().is_none()); + assert!(return_some_byval().is_some()); +} + +#[wasm_bindgen_test] +fn export_by_value() { + test_option_values(); +} + +#[wasm_bindgen] +pub fn rust_take_none_byval(t: Option) { + assert!(t.is_none()); +} + +#[wasm_bindgen] +pub fn rust_take_some_byval(t: Option) { + assert!(t.is_some()); +} + +#[wasm_bindgen] +pub fn rust_return_none_byval() -> Option { + None +} + +#[wasm_bindgen] +pub fn rust_return_some_byval() -> Option { + Some(MyType::new()) +} + +#[wasm_bindgen_test] +fn import_by_ref() { + take_none_byref(None); + take_some_byref(Some(&MyType::new())); +} -- cgit v1.2.3