Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions itest/rust/src/builtin_tests/string/gstring_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ fn string_substr() {
assert_eq!(string.substr(2..=4), "abl".into());
}

// TODO(v0.5): enable after https://github.com/godotengine/godot/pull/113044 is merged.
#[itest(skip)]
#[itest]
fn gstring_find() {
let s = GString::from("Hello World");

Expand Down
10 changes: 5 additions & 5 deletions itest/rust/src/object_tests/property_template_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ fn property_template_test(ctx: &TestContext) {
continue;
};

let mut rust_usage = rust_prop.at("usage").to::<i64>();
let mut rust_usage = rust_prop.at("usage").to::<PropertyUsageFlags>();

// The GDSscript variables are script variables, and so have `PROPERTY_USAGE_SCRIPT_VARIABLE` set.
// Before 4.3, `PROPERTY_USAGE_SCRIPT_VARIABLE` did the same thing as `PROPERTY_USAGE_STORAGE` and
// so GDScript didn't set both if it didn't need to.
if GdextBuild::before_api("4.3") {
if rust_usage == PropertyUsageFlags::STORAGE.ord() as i64 {
rust_usage = PropertyUsageFlags::SCRIPT_VARIABLE.ord() as i64
if rust_usage == PropertyUsageFlags::STORAGE {
rust_usage = PropertyUsageFlags::SCRIPT_VARIABLE
} else {
rust_usage |= PropertyUsageFlags::SCRIPT_VARIABLE.ord() as i64;
rust_usage |= PropertyUsageFlags::SCRIPT_VARIABLE;
}
} else {
rust_usage |= PropertyUsageFlags::SCRIPT_VARIABLE.ord() as i64;
rust_usage |= PropertyUsageFlags::SCRIPT_VARIABLE;
}

rust_prop.set("usage", rust_usage);
Expand Down
24 changes: 12 additions & 12 deletions itest/rust/src/object_tests/property_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use godot::builtin::{
use godot::classes::{INode, IRefCounted, Node, Object, RefCounted, Resource, Texture};
use godot::global::{PropertyHint, PropertyUsageFlags};
use godot::meta::{GodotConvert, PropertyHintInfo, ToGodot};
use godot::obj::{Base, EngineBitfield, EngineEnum, Gd, NewAlloc, NewGd, OnEditor};
use godot::obj::{Base, Gd, NewAlloc, NewGd, OnEditor};
use godot::register::property::{Export, Var};
use godot::register::{godot_api, Export, GodotClass, GodotConvert, Var};
use godot::test::itest;
Expand Down Expand Up @@ -454,10 +454,10 @@ fn derive_export() {
.unwrap();
// `class_name` should be empty for non-Object variants.
check_property(&property, "class_name", "");
check_property(&property, "type", VariantType::INT.ord());
check_property(&property, "hint", PropertyHint::ENUM.ord());
check_property(&property, "type", VariantType::INT);
check_property(&property, "hint", PropertyHint::ENUM);
check_property(&property, "hint_string", "A:0,B:1,C:2");
check_property(&property, "usage", PropertyUsageFlags::DEFAULT.ord());
check_property(&property, "usage", PropertyUsageFlags::DEFAULT);
}

#[derive(GodotClass)]
Expand Down Expand Up @@ -489,13 +489,13 @@ fn export_resource() {
.find(|c| c.get_or_nil("name") == "my_resource".to_variant())
.unwrap();
check_property(&property, "class_name", "CustomResource");
check_property(&property, "type", VariantType::OBJECT.ord());
check_property(&property, "hint", PropertyHint::RESOURCE_TYPE.ord());
check_property(&property, "type", VariantType::OBJECT);
check_property(&property, "hint", PropertyHint::RESOURCE_TYPE);
check_property(&property, "hint_string", "CustomResource");
check_property(
&property,
"usage",
PropertyUsageFlags::DEFAULT.ord() | PropertyUsageFlags::EDITOR_INSTANTIATE_OBJECT.ord(),
PropertyUsageFlags::DEFAULT | PropertyUsageFlags::EDITOR_INSTANTIATE_OBJECT,
);

let property = class
Expand All @@ -504,10 +504,10 @@ fn export_resource() {
.find(|c| c.get_or_nil("name") == "renamed_resource".to_variant())
.unwrap();
check_property(&property, "class_name", "NewNameCustomResource");
check_property(&property, "type", VariantType::OBJECT.ord());
check_property(&property, "hint", PropertyHint::RESOURCE_TYPE.ord());
check_property(&property, "type", VariantType::OBJECT);
check_property(&property, "hint", PropertyHint::RESOURCE_TYPE);
check_property(&property, "hint_string", "NewNameCustomResource");
check_property(&property, "usage", PropertyUsageFlags::DEFAULT.ord());
check_property(&property, "usage", PropertyUsageFlags::DEFAULT);

class.free();
}
Expand Down Expand Up @@ -551,9 +551,9 @@ fn override_export() {
.find(|c| c.get_or_nil("name") == "resource".to_variant())
.unwrap();

check_property(&property, "hint", PropertyHint::GLOBAL_FILE.ord());
check_property(&property, "hint", PropertyHint::GLOBAL_FILE);
check_property(&property, "hint_string", "SomethingRandom");
check_property(&property, "usage", PropertyUsageFlags::GROUP.ord());
check_property(&property, "usage", PropertyUsageFlags::GROUP);
}

fn check_property(property: &Dictionary, key: &str, expected: impl ToGodot) {
Expand Down
Loading