Skip to content

Commit 5a626c5

Browse files
committed
Clean up some tests
1 parent a7b1023 commit 5a626c5

File tree

7 files changed

+26
-46
lines changed

7 files changed

+26
-46
lines changed

godot-codegen/src/conv/type_conversions.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ fn to_hardcoded_rust_ident(full_ty: &GodotTy) -> Option<&str> {
5151

5252
// Others
5353
("bool", None) => "bool",
54-
("String", None) =>
55-
"GString",
56-
("Array", None) =>
57-
"VariantArray"
58-
,
54+
("String", None) => "GString",
55+
("Array", None) => "VariantArray",
5956

6057
// Types needed for native structures mapping
6158
("uint8_t", None) => "u8",

godot-core/src/global/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn instance_from_id(instance_id: i64) -> Option<Gd<crate::classes::Object>>
5050
#[deprecated = "Instance utilities in `godot::global` will be removed. Use methods on `Gd` and `InstanceId` instead.\n\
5151
For detailed reasons, see https://github.com/godot-rust/gdext/pull/892."]
5252
pub fn is_instance_valid(instance: Variant) -> bool {
53-
crate::gen::utilities::is_instance_valid(instance)
53+
crate::gen::utilities::is_instance_valid(&instance)
5454
}
5555

5656
#[deprecated = "Instance utilities in `godot::global` will be removed. Use methods on `Gd` and `InstanceId` instead.\n\

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

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ fn variant_get_type() {
179179
let variant = gstr("hello").to_variant();
180180
assert_eq!(variant.get_type(), VariantType::STRING);
181181

182+
let variant = sname("hello").to_variant();
183+
assert_eq!(variant.get_type(), VariantType::STRING_NAME);
184+
182185
let variant = TEST_BASIS.to_variant();
183186
assert_eq!(variant.get_type(), VariantType::BASIS)
184187
}
@@ -263,14 +266,14 @@ fn variant_evaluate() {
263266
evaluate(VariantOperator::MULTIPLY, 5, 2.5, 12.5);
264267

265268
evaluate(VariantOperator::EQUAL, gstr("hello"), gstr("hello"), true);
266-
evaluate(VariantOperator::EQUAL, gstr("hello"), gname("hello"), true);
267-
evaluate(VariantOperator::EQUAL, gname("rust"), gstr("rust"), true);
268-
evaluate(VariantOperator::EQUAL, gname("rust"), gname("rust"), true);
269+
evaluate(VariantOperator::EQUAL, gstr("hello"), sname("hello"), true);
270+
evaluate(VariantOperator::EQUAL, sname("rust"), gstr("rust"), true);
271+
evaluate(VariantOperator::EQUAL, sname("rust"), sname("rust"), true);
269272

270273
evaluate(VariantOperator::NOT_EQUAL, gstr("hello"), gstr("hallo"), true);
271-
evaluate(VariantOperator::NOT_EQUAL, gstr("hello"), gname("hallo"), true);
272-
evaluate(VariantOperator::NOT_EQUAL, gname("rust"), gstr("rest"), true);
273-
evaluate(VariantOperator::NOT_EQUAL, gname("rust"), gname("rest"), true);
274+
evaluate(VariantOperator::NOT_EQUAL, gstr("hello"), sname("hallo"), true);
275+
evaluate(VariantOperator::NOT_EQUAL, sname("rust"), gstr("rest"), true);
276+
evaluate(VariantOperator::NOT_EQUAL, sname("rust"), sname("rest"), true);
274277

275278
evaluate_fail(VariantOperator::EQUAL, 1, true);
276279
evaluate_fail(VariantOperator::EQUAL, 0, false);
@@ -391,28 +394,7 @@ fn variant_null_object_is_nil() {
391394
}
392395

393396
#[itest]
394-
fn variant_type_correct() {
395-
assert_eq!(Variant::nil().get_type(), VariantType::NIL);
396-
assert_eq!(0.to_variant().get_type(), VariantType::INT);
397-
assert_eq!(3.8.to_variant().get_type(), VariantType::FLOAT);
398-
assert_eq!(false.to_variant().get_type(), VariantType::BOOL);
399-
assert_eq!("string".to_variant().get_type(), VariantType::STRING);
400-
assert_eq!(
401-
StringName::from("string_name").to_variant().get_type(),
402-
VariantType::STRING_NAME
403-
);
404-
assert_eq!(
405-
VariantArray::default().to_variant().get_type(),
406-
VariantType::ARRAY
407-
);
408-
assert_eq!(
409-
Dictionary::default().to_variant().get_type(),
410-
VariantType::DICTIONARY
411-
);
412-
}
413-
414-
#[itest]
415-
fn variant_stringify_correct() {
397+
fn variant_stringify() {
416398
assert_eq!("value".to_variant().stringify(), gstr("value"));
417399
assert_eq!(Variant::nil().stringify(), gstr("<null>"));
418400
assert_eq!(true.to_variant().stringify(), gstr("true"));
@@ -428,10 +410,10 @@ fn variant_stringify_correct() {
428410
}
429411

430412
#[itest]
431-
fn variant_booleanize_correct() {
413+
fn variant_booleanize() {
432414
assert!(gstr("string").to_variant().booleanize());
433415
assert!(10.to_variant().booleanize());
434-
assert!(&varray![""].to_variant().booleanize());
416+
assert!(varray![""].to_variant().booleanize());
435417
assert!(dict! { "Key": 50 }.to_variant().booleanize());
436418

437419
assert!(!Dictionary::new().to_variant().booleanize());
@@ -442,7 +424,7 @@ fn variant_booleanize_correct() {
442424
}
443425

444426
#[itest]
445-
fn variant_hash_correct() {
427+
fn variant_hash() {
446428
let hash_is_not_0 = [
447429
dict! {}.to_variant(),
448430
gstr("").to_variant(),
@@ -583,6 +565,6 @@ fn gstr(s: &str) -> GString {
583565
GString::from(s)
584566
}
585567

586-
fn gname(s: &str) -> StringName {
568+
fn sname(s: &str) -> StringName {
587569
StringName::from(s)
588570
}

itest/rust/src/engine_tests/utilities_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ fn utilities_max() {
8585
fn utilities_is_instance_valid() {
8686
let node = Node3D::new_alloc();
8787
let variant = Variant::from(node.clone());
88-
assert!(is_instance_valid(&variant));
88+
assert!(is_instance_valid(variant.clone()));
8989

9090
node.free();
91-
assert!(!is_instance_valid(&variant));
91+
assert!(!is_instance_valid(variant));
9292
}

itest/rust/src/object_tests/enum_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use godot::global::{Orientation, Key};
1414
use std::collections::HashSet;
1515

1616
#[itest]
17-
fn enum_ords_correct() {
17+
fn enum_ords() {
1818
use godot::obj::EngineEnum;
1919
assert_eq!(CursorShape::CURSOR_ARROW.ord(), 0);
2020
assert_eq!(CursorShape::CURSOR_IBEAM.ord(), 1);
@@ -73,7 +73,7 @@ fn add_surface_from_arrays() {
7373
}
7474

7575
#[itest]
76-
fn enum_as_str_correct() {
76+
fn enum_as_str() {
7777
use godot::obj::EngineEnum;
7878
assert_eq!(Orientation::Vertical.as_str(), "VERTICAL");
7979
assert_eq!(Orientation::Horizontal.as_str(), "HORIZONTAL");
@@ -86,7 +86,7 @@ fn enum_as_str_correct() {
8686
}
8787

8888
#[itest]
89-
fn enum_godot_name_correct() {
89+
fn enum_godot_name() {
9090
use godot::obj::EngineEnum;
9191
assert_eq!(Orientation::Vertical.godot_name(), Orientation::Vertical.as_str());
9292
assert_eq!(Orientation::Horizontal.godot_name(), Orientation::Vertical.as_str());

itest/rust/src/object_tests/virtual_methods_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ fn test_get_called() {
609609
}
610610

611611
#[itest]
612-
fn test_get_returns_correct() {
612+
fn test_get_returns() {
613613
let mut obj = GetTest::new_gd();
614614

615615
{
@@ -636,7 +636,7 @@ fn test_set_called() {
636636
}
637637

638638
#[itest]
639-
fn test_set_sets_correct() {
639+
fn test_set_sets() {
640640
let mut obj = SetTest::new_gd();
641641

642642
assert_eq!(obj.bind().always_set_to_100, i64::default());

itest/rust/src/register_tests/func_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ impl GdSelfObj {
196196
"update_internal_signal".into(),
197197
&[new_internal.to_variant()],
198198
);
199-
return this.bind().internal_value;
199+
200+
this.bind().internal_value
200201
}
201202

202203
#[func(gd_self)]

0 commit comments

Comments
 (0)