Skip to content

Commit 2ac981f

Browse files
committed
Add should_panic samples and tests
1 parent 2328c43 commit 2ac981f

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

crates/futures/tests/tests.rs

+12
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,15 @@ async fn can_use_an_async_iterable_as_stream() {
155155
assert_eq!(stream.next().await, Some(Ok(JsValue::from(24))));
156156
assert_eq!(stream.next().await, None);
157157
}
158+
159+
#[wasm_bindgen_test]
160+
#[should_panic]
161+
async fn should_panic() {
162+
panic!()
163+
}
164+
165+
#[wasm_bindgen_test]
166+
#[should_panic = "error message"]
167+
async fn should_panic() {
168+
panic!("error message")
169+
}

crates/test/sample/tests/common/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ fn panic_before_result_fail() -> Result<(), Box<dyn std::error::Error>> {
5151
#[allow(unreachable_code)]
5252
Err("failed via Result".into())
5353
}
54+
55+
#[wasm_bindgen_test]
56+
#[should_panic]
57+
fn should_panic() {
58+
panic!()
59+
}
60+
61+
#[wasm_bindgen_test]
62+
#[should_panic = "error message"]
63+
fn should_panic() {
64+
panic!("error message")
65+
}

tests/wasm/should_panic.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[wasm_bindgen_test]
2+
#[should_panic]
3+
fn should_panic() {
4+
panic!()
5+
}
6+
7+
#[wasm_bindgen_test]
8+
#[should_panic = "error message"]
9+
fn should_panic() {
10+
panic!("error message")
11+
}

0 commit comments

Comments
 (0)