Skip to content

Commit f93498c

Browse files
authored
Merge pull request #950 from Yarwin/add-test-to-prevent-regression
Add test that checks if custom callables don't crash when Err() is returned.
2 parents b938b41 + 81533a8 commit f93498c

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
@@ -115,7 +115,7 @@ fn callable_call_return() {
115115
callable.callv(&varray![10]),
116116
10.to_variant().stringify().to_variant()
117117
);
118-
// errors in godot but does not crash
118+
// Errors in Godot, but should not crash.
119119
assert_eq!(callable.callv(&varray!["string"]), Variant::nil());
120120
}
121121

@@ -196,6 +196,14 @@ pub mod custom_callable {
196196
assert_eq!(sum3, 0.to_variant());
197197
}
198198

199+
#[itest]
200+
fn callable_custom_with_err() {
201+
let callable_with_err =
202+
Callable::from_fn("on_error_doesnt_crash", |_args: &[&Variant]| Err(()));
203+
// Errors in Godot, but should not crash.
204+
assert_eq!(callable_with_err.callv(&varray![]), Variant::nil());
205+
}
206+
199207
#[itest]
200208
fn callable_from_fn_eq() {
201209
let a = Callable::from_fn("sum", sum);

0 commit comments

Comments
 (0)