chore: add GUT test framework

This commit is contained in:
xiaji
2026-05-29 09:16:10 +08:00
parent 5741ba1dc0
commit 07fc763413
808 changed files with 76903 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
[gd_scene load_steps=3 format=3 uid="uid://ddt7uesww2edw"]
[ext_resource type="Script" uid="uid://db7q3qiiwj01e" path="res://test/resources/test_assert_setget_test_objects/test_node.gd" id="1"]
[ext_resource type="Script" uid="uid://wtprqn8wqc6s" path="res://test/resources/test_assert_setget_test_objects/test_scene.gd" id="2"]
[node name="SceneMock" type="Node2D"]
script = ExtResource("2")
[node name="NodeChildMock" type="Node" parent="."]
script = ExtResource("1")

View File

@@ -0,0 +1,31 @@
[gd_scene load_steps=2 format=3 uid="uid://b3f8i5l6l0hfq"]
[sub_resource type="Resource" id="Resource_ilpij"]
metadata/__load_path__ = "res://test/resources/test_assert_setget_test_objects/control_child_mock.gd"
[node name="HealthBar" type="Control"]
offset_right = 130.0
offset_bottom = 46.0
script = SubResource("Resource_ilpij")
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ProgressBar" type="ProgressBar" parent="."]
anchor_right = 1.0
offset_bottom = 14.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="."]
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -14.0
text = "%s / %s"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -0,0 +1,17 @@
extends Node
@export var max_hp: int = 0
@export var current_hp: int = 0 :
get:
return current_hp
set(value):
current_hp = clamp(value, 0, max_hp)
func set_max_hp(value: int) -> void:
if value < 0:
value = 0
max_hp = value
func get_max_hp() -> int:
return max_hp

View File

@@ -0,0 +1 @@
uid://bbrki65o4iklb

View File

@@ -0,0 +1,17 @@
extends Control
const Health = preload("res://test/resources/test_assert_setget_test_objects/readme_examples/health.gd")
var health: Health = null :
get:
return health
set(node):
health = node
@onready var progress_bar = $ProgressBar
@onready var label = $Label
func update() -> void:
if health != null:
label.text = "%s / %s" %[health.current_hp, health.max_hp]
progress_bar.max_value = health.max_hp
progress_bar.value = health.current_hp

View File

@@ -0,0 +1 @@
uid://d1r04sabmturw

View File

@@ -0,0 +1,77 @@
extends Node
var _priv_var = 'asdf'
# -------------------------------------------------
var no_setget = 1
# -------------------------------------------------
var has_setter = 2 :
set(val):
has_setter = val
# -------------------------------------------------
var has_getter = 3 :
get:
return has_getter
set(val):
has_getter = val
# -------------------------------------------------
var has_both = 4 :
get:
return has_both
set(val):
has_both = val
# -------------------------------------------------
var non_default_both = 5 :
get:
return non_default_both
set(val):
non_default_both = val
# -------------------------------------------------
var non_default_setter = 6 :
get:
return non_default_setter
set(val):
non_default_setter = val
# -------------------------------------------------
var non_default_getter = 7 :
get:
return non_default_getter
set(val):
non_default_getter = val
# -------------------------------------------------
# dnu = "does not use"
var has_both_dnu_setget = 8
func get_has_both_dnu_setget():
return has_both_dnu_setget
func set_has_both_dnu_setget(val):
has_both_dnu_setget = val
# -------------------------------------------------
var typed_setter:int = 9 :
get:
return typed_setter
set(val):
typed_setter = val
var _backed_property = 10
var backed_property = 10 :
get: return _backed_property
set(val): _backed_property = val
var _backed_get_broke = 11
var backed_get_broke = 11 :
get: return backed_get_broke
set(val): _backed_get_broke = val
var _backed_set_broke = 12
var backed_set_broke = 12 :
get: return _backed_set_broke
set(val): backed_set_broke = val

View File

@@ -0,0 +1 @@
uid://db7q3qiiwj01e

View File

@@ -0,0 +1,10 @@
extends Node2D
@onready var node_with_setter_getter = $NodeChildMock :
get:
return node_with_setter_getter
set(node):
if node_with_setter_getter != null:
node_with_setter_getter.queue_free()
node_with_setter_getter = node

View File

@@ -0,0 +1 @@
uid://wtprqn8wqc6s