Skip to content

Commit

Permalink
Add test that checks if custom callables don't crash when Err() is re…
Browse files Browse the repository at this point in the history
…turned.
  • Loading branch information
Yarwin committed Nov 11, 2024
1 parent 8beef9d commit 81533a8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion itest/rust/src/builtin_tests/containers/callable_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn callable_call_return() {
callable.callv(&varray![10]),
10.to_variant().stringify().to_variant()
);
// errors in godot but does not crash
// Errors in Godot, but should not crash.
assert_eq!(callable.callv(&varray!["string"]), Variant::nil());
}

Expand Down Expand Up @@ -190,6 +190,14 @@ pub mod custom_callable {
assert_eq!(sum3, 0.to_variant());
}

#[itest]
fn callable_custom_with_err() {
let callable_with_err =
Callable::from_fn("on_error_doesnt_crash", |_args: &[&Variant]| Err(()));
// Errors in Godot, but should not crash.
assert_eq!(callable_with_err.callv(&varray![]), Variant::nil());
}

#[itest]
fn callable_from_fn_eq() {
let a = Callable::from_fn("sum", sum);
Expand Down

0 comments on commit 81533a8

Please sign in to comment.