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,4 @@
var param1 = -1
func _init(p1):
param1 = p1

View File

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

View File

@@ -0,0 +1,55 @@
const SOME_CONSTANT = 5
enum SOME_VALUES {
VALUE_1,
VALUE_2,
VALUE_3
}
func return_passed(p1='a', p2='b'):
return str(p1, p2)
func call_me(p1, p2 = 2):
return str('called with ', p1, ', ', p2)
func call_call_me(p1):
return call_me(p1)
func default_array(p1=[]):
pass
func default_int(p1=SOME_CONSTANT):
pass
func default_string(p1='s'):
pass
func defaulted_second_parameter(p1, p2='p2'):
return str(p1, p2)
func default_last_two_boolean(p1, p2=true, p3=false):
pass
func default_vector3(p1=Vector3(1, 1, 1)):
pass
func default_typed_vector3(p1:Vector3=Vector3(1, 1, 1)):
pass
func default_color(p1=Color(.5, .5, .5)):
pass
func default_typed_color(p1:Color=Color(.6, .6, .6)):
pass
func default_enum(p1=SOME_VALUES.VALUE_1):
pass
func default_typed_enum(p1:SOME_VALUES = SOME_VALUES.VALUE_1):
pass
func no_defaults(p1, p2, p3):
pass

View File

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

View File

@@ -0,0 +1,16 @@
extends Node2D
var _value = 0
func get_value():
return _value
func set_value(val):
_value = val
func has_one_param(one):
pass
func has_two_params_one_default(one, two=null):
pass

View File

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

View File

@@ -0,0 +1 @@
extends Window

View File

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

View File

@@ -0,0 +1,73 @@
extends Node
var _value = 0
var should_might_await_await = true
signal signal_signal
func _ready():
pass
func _init():
pass
func get_value():
return _value
func set_value(val):
_value = val
func has_one_param(one):
pass
func has_two_params_one_default(one, two=null):
pass
func get_position():
return get_position()
func has_string_and_array_defaults(string_param = "asdf", array_param = [1]):
pass
func this_just_does_an_await():
await get_tree().create_timer(1)
func this_is_a_coroutine():
return await get_tree().create_timer(1)
func calls_coroutine():
return await this_is_a_coroutine()
func does_something_then_calls_coroutine_then_does_something_else():
print('This is before the coroutine call')
await this_is_a_coroutine()
print('something else')
return 10
func might_await(should, some_default=3):
if(should):
print('awaiting')
await this_is_a_coroutine()
else:
print('not awaiting')
return
func await_seconds(s):
await get_tree().create_timer(s).timeout
func might_await_no_return(some_default=3):
if(should_might_await_await):
print('awaiting')
await this_is_a_coroutine()
else:
print('not awaiting')
func uses_await_response():
var foo = await this_is_a_coroutine()
func default_is_value(val = _value):
return val

View File

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

View File

@@ -0,0 +1,12 @@
extends Node2D
@onready var label = get_node('Label')
func return_hello():
return 'hello'
func set_label_text(text):
$Label.set_text(text)
func get_button():
return $MyPanel/MyButton

View File

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

View File

@@ -0,0 +1,23 @@
[gd_scene load_steps=2 format=3 uid="uid://8cnd7xm6f4m1"]
[ext_resource type="Script" uid="uid://w3axo60f4xar" path="res://test/resources/doubler_test_objects/double_me_scene.gd" id="1"]
[node name="Node2D" type="Node2D"]
script = ExtResource("1")
[node name="Label" type="Label" parent="."]
offset_right = 40.0
offset_bottom = 14.0
text = "This is a label"
[node name="MyPanel" type="Panel" parent="."]
offset_left = 40.0
offset_top = 42.0
offset_right = 178.0
offset_bottom = 131.0
[node name="MyButton" type="Button" parent="MyPanel"]
offset_left = 25.0
offset_top = 27.0
offset_right = 116.0
offset_bottom = 66.0

View File

@@ -0,0 +1,5 @@
static func this_is_a_static_method():
return true
func this_is_not_static():
return true

View File

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

View File

@@ -0,0 +1,44 @@
class_name GutDoubleTestInnerClasses
var _value = 1
func get_value():
return _value
func set_value(val):
_value = val
class InnerA:
func get_a():
return 'a'
# Needed another class with same method as an inner class to test
# stubbing.
class AnotherInnerA:
func get_a():
return 'aia'
class InnerB:
func get_b():
return 'b'
class InnerB1:
func get_b1():
return 'b1'
class InnerCA:
extends InnerA
func get_ca():
return 'ca'
class InnerWithSignals:
signal signal_signal
class InnerExtendsNode2D:
extends Node2D

View File

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