Skip to content

Commit

Permalink
-Fixes godot-rust#138.
Browse files Browse the repository at this point in the history
-Add integration tests.
  • Loading branch information
thebigG committed Mar 19, 2023
1 parent 55c4d3a commit 418f6d3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
5 changes: 3 additions & 2 deletions godot-core/src/builtin/meta/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ macro_rules! impl_signature_for_tuple {
unsafe { <$R as sys::GodotFuncMarshal>::try_write_sys(&ret_val, ret) }
.unwrap_or_else(|e| return_error::<$R>(method_name, &e));

// FIXME is inc_ref needed here?
// std::mem::forget(ret_val);
//Note: we want to prevent the destructor from being run, since we pass ownership to the caller.
// For details look at https://github.com/godot-rust/gdext/pull/165
std::mem::forget(ret_val);
}
}
};
Expand Down
41 changes: 41 additions & 0 deletions itest/godot/InheritTests.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extends ArrayTest

var _assertion_failed: bool = false

## Asserts that `what` is `true`, but does not abort the test. Returns `what` so you can return
## early from the test function if the assertion failed.
func assert_that(what: bool, message: String = "") -> bool:
if what:
return true

_assertion_failed = true
if message:
print("assertion failed: %s" % message)
else:
print("assertion failed")
return false

func assert_eq(left, right, message: String = "") -> bool:
if left == right:
return true

_assertion_failed = true
if message:
print("assertion failed: %s\n left: %s\n right: %s" % [message, left, right])
else:
print("assertion failed: `(left == right)`\n left: %s\n right: %s" % [left, right])
return false



# Called when the node enters the scene tree for the first time.
func _ready():
pass

func test_vector_array_return_from_user_func():
var array: Array = return_typed_array(2)
assert_eq(array, [1,2])

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
1 change: 1 addition & 0 deletions itest/godot/TestRunner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func _ready():
var gdscript_suites: Array = [
preload("res://ManualFfiTests.gd").new(),
preload("res://gen/GenFfiTests.gd").new(),
preload("res://InheritTests.gd").new()
]

var gdscript_tests: Array = []
Expand Down

0 comments on commit 418f6d3

Please sign in to comment.