Skip to content

Commit 81533a8

Browse files
committed
Add test that checks if custom callables don't crash when Err() is returned.
1 parent 8beef9d commit 81533a8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

itest/rust/src/builtin_tests/containers/callable_test.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn callable_call_return() {
109109
callable.callv(&varray![10]),
110110
10.to_variant().stringify().to_variant()
111111
);
112-
// errors in godot but does not crash
112+
// Errors in Godot, but should not crash.
113113
assert_eq!(callable.callv(&varray!["string"]), Variant::nil());
114114
}
115115

@@ -190,6 +190,14 @@ pub mod custom_callable {
190190
assert_eq!(sum3, 0.to_variant());
191191
}
192192

193+
#[itest]
194+
fn callable_custom_with_err() {
195+
let callable_with_err =
196+
Callable::from_fn("on_error_doesnt_crash", |_args: &[&Variant]| Err(()));
197+
// Errors in Godot, but should not crash.
198+
assert_eq!(callable_with_err.callv(&varray![]), Variant::nil());
199+
}
200+
193201
#[itest]
194202
fn callable_from_fn_eq() {
195203
let a = Callable::from_fn("sum", sum);

0 commit comments

Comments
 (0)