Adding log.gd
This commit is contained in:
parent
eb32d6614e
commit
4522259397
547 changed files with 46844 additions and 0 deletions
17
addons/gdUnit4/test/core/resources/Area4D.txt
Normal file
17
addons/gdUnit4/test/core/resources/Area4D.txt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class Area4D extends Resource:
|
||||
|
||||
const SOUND := 1
|
||||
const ATMOSPHERE := 2
|
||||
var _meta := Dictionary()
|
||||
|
||||
func _init(_x :int, atmospere :AtmosphereData = null):
|
||||
_meta[ATMOSPHERE] = atmospere
|
||||
|
||||
func get_sound() -> SoundData:
|
||||
# sounds are optional
|
||||
if _meta.has(SOUND):
|
||||
return _meta[SOUND] as SoundData
|
||||
return null
|
||||
|
||||
func get_atmoshere() -> AtmosphereData:
|
||||
return _meta[ATMOSPHERE] as AtmosphereData
|
||||
22
addons/gdUnit4/test/core/resources/AtmosphereData.txt
Normal file
22
addons/gdUnit4/test/core/resources/AtmosphereData.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class AtmosphereData:
|
||||
enum {
|
||||
WATER,
|
||||
AIR,
|
||||
SMOKY,
|
||||
}
|
||||
var _toxigen :float
|
||||
var _type :int
|
||||
|
||||
func _init(type := AIR, toxigen := 0.0):
|
||||
_type = type
|
||||
_toxigen = toxigen
|
||||
# some comment, and an row staring with an space to simmulate invalid formatting
|
||||
|
||||
|
||||
# seter func with default values
|
||||
func set_data(type := AIR, toxigen := 0.0) :
|
||||
_type = type
|
||||
_toxigen = toxigen
|
||||
|
||||
static func to_atmosphere(_value :Dictionary) -> AtmosphereData:
|
||||
return null
|
||||
BIN
addons/gdUnit4/test/core/resources/GdUnitRunner_old_format.cfg
Normal file
BIN
addons/gdUnit4/test/core/resources/GdUnitRunner_old_format.cfg
Normal file
Binary file not shown.
5
addons/gdUnit4/test/core/resources/SoundData.txt
Normal file
5
addons/gdUnit4/test/core/resources/SoundData.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class SoundData:
|
||||
@warning_ignore("unused_private_class_variable")
|
||||
var _sample :String
|
||||
@warning_ignore("unused_private_class_variable")
|
||||
var _randomnes :float
|
||||
|
|
@ -0,0 +1 @@
|
|||
xxx
|
||||
|
|
@ -0,0 +1 @@
|
|||
xxx
|
||||
|
|
@ -0,0 +1 @@
|
|||
xxx
|
||||
|
|
@ -0,0 +1 @@
|
|||
xxx
|
||||
|
|
@ -0,0 +1 @@
|
|||
xxx
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
class_name PascalCaseWithClassName
|
||||
extends Resource
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
extends RefCounted
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
class_name SnakeCaseWithClassName
|
||||
extends Resource
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
extends RefCounted
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
class_name BaseTest
|
||||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
func before():
|
||||
pass
|
||||
|
||||
|
||||
func after():
|
||||
pass
|
||||
|
||||
|
||||
func before_test():
|
||||
pass
|
||||
|
||||
|
||||
func after_test():
|
||||
pass
|
||||
|
||||
|
||||
func test_foo1() -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
class_name ExtendedTest
|
||||
extends BaseTest
|
||||
|
||||
|
||||
func before_test():
|
||||
pass
|
||||
|
||||
|
||||
func after_test():
|
||||
pass
|
||||
|
||||
|
||||
func test_foo2() -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
extends ExtendedTest
|
||||
|
||||
func test_foo3() -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
func test_foo1() -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
extends "res://addons/gdUnit4/test/core/resources/scan_testsuite_inheritance/by_class_path/BaseTest.gd"
|
||||
|
||||
func test_foo2() -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
extends "res://addons/gdUnit4/test/core/resources/scan_testsuite_inheritance/by_class_path/ExtendedTest.gd"
|
||||
|
||||
func test_foo3() -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
extends PanelContainer
|
||||
|
||||
|
||||
# Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data.
|
||||
# Returns null if there is no data to drag.
|
||||
# Controls that want to receive drop data should implement can_drop_data() and drop_data().
|
||||
# position is local to this control. Drag may be forced with force_drag().
|
||||
func _get_drag_data(_position: Vector2) -> Variant:
|
||||
var x :TextureRect = $TextureRect
|
||||
var data: = {texture = x.texture}
|
||||
var drag_texture := x.duplicate()
|
||||
drag_texture.size = x.size
|
||||
drag_texture.position = x.global_position * -0.2
|
||||
|
||||
# set drag preview
|
||||
var control := Panel.new()
|
||||
control.add_child(drag_texture)
|
||||
# center texture relative to mouse pos
|
||||
set_drag_preview(control)
|
||||
return data
|
||||
|
||||
|
||||
# Godot calls this method to test if data from a control's get_drag_data() can be dropped at position. position is local to this control.
|
||||
func _can_drop_data(_position: Vector2, data :Variant) -> bool:
|
||||
return typeof(data) == TYPE_DICTIONARY and data.has("texture")
|
||||
|
||||
|
||||
# Godot calls this method to pass you the data from a control's get_drag_data() result.
|
||||
# Godot first calls can_drop_data() to test if data is allowed to drop at position where position is local to this control.
|
||||
func _drop_data(_position: Vector2, data :Variant) -> void:
|
||||
var drag_texture :Texture = data["texture"]
|
||||
if drag_texture != null:
|
||||
$TextureRect.texture = drag_texture
|
||||
|
||||
|
||||
# Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See accept_event().
|
||||
func _gui_input(_event):
|
||||
#prints("Panel _gui_input", _event.as_text())
|
||||
#if _event is InputEventMouseButton:
|
||||
# prints("Panel _gui_input", _event.as_text())
|
||||
pass
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ca2rr3dan4vvw"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/DragAndDropControl.gd" id="1"]
|
||||
|
||||
[node name="Panel" type="PanelContainer"]
|
||||
offset_left = 245.0
|
||||
offset_top = 232.0
|
||||
offset_right = 350.0
|
||||
offset_bottom = 337.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
extends Control
|
||||
|
||||
@onready var texture = preload("res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/icon.png")
|
||||
|
||||
func _ready():
|
||||
# set initial drag texture
|
||||
$left/TextureRect.texture = texture
|
||||
|
||||
|
||||
# Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See accept_event().
|
||||
func _gui_input(_event):
|
||||
#prints("Game _gui_input", _event.as_text())
|
||||
pass
|
||||
|
||||
|
||||
func _on_Button_button_down():
|
||||
# print("BUTTON DOWN")
|
||||
pass
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://skueh3d5qn46"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/DragAndDropTestScene.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca2rr3dan4vvw" path="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/DragAndDropControl.tscn" id="2_u5ccv"]
|
||||
|
||||
[node name="DragAndDropScene" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="left" parent="." instance=ExtResource("2_u5ccv")]
|
||||
layout_mode = 0
|
||||
offset_left = 250.0
|
||||
offset_top = 240.0
|
||||
offset_right = 355.0
|
||||
offset_bottom = 345.0
|
||||
auto_translate = false
|
||||
localize_numeral_system = false
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="right" parent="." instance=ExtResource("2_u5ccv")]
|
||||
layout_mode = 0
|
||||
offset_left = 370.0
|
||||
offset_top = 240.0
|
||||
offset_right = 475.0
|
||||
offset_bottom = 345.0
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 243.0
|
||||
offset_top = 40.0
|
||||
offset_right = 479.0
|
||||
offset_bottom = 200.0
|
||||
text = "BUTTON"
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[connection signal="button_down" from="Button" to="." method="_on_Button_button_down"]
|
||||
BIN
addons/gdUnit4/test/core/resources/scenes/drag_and_drop/icon.png
Normal file
BIN
addons/gdUnit4/test/core/resources/scenes/drag_and_drop/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://di6ovw8bnk7wg"
|
||||
path="res://.godot/imported/icon.png-50a1939c45a5f06328a9e414b58963b1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-50a1939c45a5f06328a9e414b58963b1.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
extends Control
|
||||
|
||||
var _player_jump_action_released := false
|
||||
|
||||
# enable for manual testing
|
||||
func __init():
|
||||
var event := InputEventKey.new()
|
||||
event.keycode = KEY_SPACE
|
||||
InputMap.add_action("player_jump")
|
||||
InputMap.action_add_event("player_jump", event)
|
||||
|
||||
|
||||
func _input(event):
|
||||
_player_jump_action_released = Input.is_action_just_released("player_jump", true)
|
||||
#prints("_input2:player_jump", Input.is_action_just_released("player_jump"), Input.is_action_just_released("player_jump", true))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cvklb72mxqh1h"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/input_actions/InputEventTestScene.gd" id="1_wslmn"]
|
||||
|
||||
[node name="InputEventTestScene" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_wslmn")
|
||||
15
addons/gdUnit4/test/core/resources/scenes/simple_scene.gd
Normal file
15
addons/gdUnit4/test/core/resources/scenes/simple_scene.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extends Node2D
|
||||
|
||||
class Player extends Node:
|
||||
var position :Vector3 = Vector3.ZERO
|
||||
|
||||
|
||||
func _init():
|
||||
set_name("Player")
|
||||
|
||||
func is_on_floor() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _ready():
|
||||
add_child(Player.new(), true)
|
||||
11
addons/gdUnit4/test/core/resources/scenes/simple_scene.tscn
Normal file
11
addons/gdUnit4/test/core/resources/scenes/simple_scene.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cn8ucy2rheu0f"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://t80a6k3vyrrd" path="res://icon.png" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/simple_scene.gd" id="2"]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(504, 252)
|
||||
texture = ExtResource("1")
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class_name ScriptWithClassName
|
||||
extends Resource
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
extends RefCounted
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
17
addons/gdUnit4/test/core/resources/sources/test_person.gd
Normal file
17
addons/gdUnit4/test/core/resources/sources/test_person.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
extends RefCounted
|
||||
|
||||
var _first_name :String
|
||||
var _last_name :String
|
||||
|
||||
func _init(first_name_ :String,last_name_ :String):
|
||||
_first_name = first_name_
|
||||
_last_name = last_name_
|
||||
|
||||
func first_name() -> String:
|
||||
return _first_name
|
||||
|
||||
func last_name() -> String:
|
||||
return _last_name
|
||||
|
||||
func fully_name() -> String:
|
||||
return _first_name + " " + _last_name
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
extends Node
|
||||
|
||||
|
||||
func test_no_args():
|
||||
pass
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_with_timeout(timeout=2000):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_with_fuzzer(fuzzer := Fuzzers.rangei(-10, 22)):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_with_fuzzer_iterations(fuzzer := Fuzzers.rangei(-10, 22), fuzzer_iterations = 10):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_with_multible_fuzzers(fuzzer_a := Fuzzers.rangei(-10, 22), fuzzer_b := Fuzzers.rangei(23, 42), fuzzer_iterations = 10):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_multiline_arguments_a(fuzzer_a := Fuzzers.rangei(-10, 22), fuzzer_b := Fuzzers.rangei(23, 42),
|
||||
fuzzer_iterations = 42):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_multiline_arguments_b(
|
||||
fuzzer_a := Fuzzers.rangei(-10, 22),
|
||||
fuzzer_b := Fuzzers.rangei(23, 42),
|
||||
fuzzer_iterations = 23
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func test_multiline_arguments_c(
|
||||
timeout=2000,
|
||||
fuzzer_a := Fuzzers.rangei(-10, 22),
|
||||
fuzzer_b := Fuzzers.rangei(23, 42),
|
||||
fuzzer_iterations = 33
|
||||
) -> void:
|
||||
pass
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# this test suite simulates long running test cases
|
||||
extends GdUnitTestSuite
|
||||
@warning_ignore('unused_parameter')
|
||||
|
||||
var _stack : Array
|
||||
|
||||
func before():
|
||||
# init the stack
|
||||
_stack = []
|
||||
|
||||
func before_test():
|
||||
# clean the stack before every test run
|
||||
_stack.clear()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_multi_yielding_with_fuzzer(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 10):
|
||||
# verify the used stack is cleaned by 'before_test'
|
||||
assert_array(_stack).is_empty()
|
||||
_stack.push_back(1)
|
||||
|
||||
prints("test iteration %d" % fuzzer.iteration_index())
|
||||
prints("4")
|
||||
await get_tree().process_frame
|
||||
prints("3")
|
||||
await get_tree().process_frame
|
||||
prints("2")
|
||||
await get_tree().process_frame
|
||||
prints("1")
|
||||
await get_tree().process_frame
|
||||
prints("Go")
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_multi_yielding_with_fuzzer_fail_after_3_iterations(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 10):
|
||||
prints("test iteration %d" % fuzzer.iteration_index())
|
||||
# should never be greater than 3 because we interuppted after three iterations
|
||||
assert_int(fuzzer.iteration_index()).is_less_equal(3)
|
||||
prints("4")
|
||||
await get_tree().process_frame
|
||||
prints("3")
|
||||
await get_tree().process_frame
|
||||
prints("2")
|
||||
await get_tree().process_frame
|
||||
prints("1")
|
||||
await get_tree().process_frame
|
||||
prints("Go")
|
||||
if fuzzer.iteration_index() >= 3:
|
||||
assert_bool(true).is_false()
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
namespace GdUnit4.Tests.Resources
|
||||
{
|
||||
using static Assertions;
|
||||
|
||||
// will be ignored because of missing `[TestSuite]` anotation
|
||||
public partial class NotATestSuite
|
||||
{
|
||||
[TestCase]
|
||||
public void TestFoo()
|
||||
{
|
||||
AssertBool(true).IsEqual(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case1(timeout = 1000, do_skip=1==1, skip_reason="do not run this"):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case2(skip_reason="ignored"):
|
||||
pass
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite ends with success, no failures or errors
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# this test suite ends with error on testcase1 by a timeout
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
# configure test with timeout of 2s
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case1(timeout=2000):
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
# wait 3s to let the test fail by timeout
|
||||
await await_millis(3000)
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# this test suite fails if (https://github.com/MikeSchulze/gdUnit4/issues/106) not fixed on iterating over testcases
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
add_child(auto_free(Node.new()))
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
# this test suite fails on multiple stages and detects orphans
|
||||
extends GdUnitTestSuite
|
||||
|
||||
var _orphans := Array()
|
||||
|
||||
func before():
|
||||
# create a node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
|
||||
func before_test():
|
||||
# create two node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
|
||||
|
||||
# ends with warning and 3 orphan detected
|
||||
func test_case1():
|
||||
# create three node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
|
||||
# ends with error and 4 orphan detected
|
||||
func test_case2():
|
||||
# create four node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
assert_str("test_case2").override_failure_message("faild on test_case2()").is_empty()
|
||||
|
||||
# we manually freeing the orphans from the simulated testsuite to prevent memory leaks here
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
for orphan in _orphans:
|
||||
orphan.free()
|
||||
_orphans.clear()
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# this test suite fails on multiple stages
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").override_failure_message("failed on after()").is_empty()
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").override_failure_message("failed on before_test()").is_empty()
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").override_failure_message("failed 1 on test_case1()").is_empty()
|
||||
assert_str("test_case1").override_failure_message("failed 2 on test_case1()").is_empty()
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage after()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").override_failure_message("failed on after()").is_empty()
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage after_test()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").override_failure_message("failed on after_test()").is_empty()
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage before()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").override_failure_message("failed on before()").is_empty()
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage before_test()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").override_failure_message("failed on before_test()").is_empty()
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on a single test case
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").override_failure_message("failed on test_case1()").is_empty()
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
# this test suite simulates long running test cases
|
||||
extends GdUnitTestSuite
|
||||
@warning_ignore('unused_parameter')
|
||||
|
||||
|
||||
class TestCaseStatistics:
|
||||
var _testcase_before_called := 0
|
||||
var _testcase_after_called := 0
|
||||
var _test_called := 0
|
||||
var _expected_calls :int
|
||||
|
||||
func _init(expected_calls :int):
|
||||
_expected_calls = expected_calls
|
||||
|
||||
func count_test_before_test():
|
||||
_testcase_before_called +=1
|
||||
|
||||
func count_test_after_test():
|
||||
_testcase_after_called +=1
|
||||
|
||||
func count_test():
|
||||
_test_called += 1
|
||||
|
||||
|
||||
var _metrics = {
|
||||
"test_execute_3times" : TestCaseStatistics.new(3),
|
||||
"test_execute_5times" : TestCaseStatistics.new(5)
|
||||
}
|
||||
|
||||
var _stack : Array
|
||||
var _before_called := 0
|
||||
var _after_called := 0
|
||||
|
||||
|
||||
func before():
|
||||
_before_called += 1
|
||||
# init the stack
|
||||
_stack = []
|
||||
|
||||
|
||||
func after():
|
||||
_after_called += 1
|
||||
assert_that(_before_called)\
|
||||
.override_failure_message("Expecting 'before' is called only one times")\
|
||||
.is_equal(1)
|
||||
assert_that(_after_called)\
|
||||
.override_failure_message("Expecting 'after' is called only one times")\
|
||||
.is_equal(1)
|
||||
|
||||
for test_case in _metrics.keys():
|
||||
var statistics := _metrics[test_case] as TestCaseStatistics
|
||||
assert_int(statistics._testcase_before_called)\
|
||||
.override_failure_message("Expect before_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_before_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._test_called)\
|
||||
.override_failure_message("Expect test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._test_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._testcase_after_called)\
|
||||
.override_failure_message("Expect after_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_after_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
|
||||
|
||||
func before_test():
|
||||
_metrics[__active_test_case].count_test_before_test()
|
||||
# clean the stack before every test run
|
||||
_stack.clear()
|
||||
|
||||
|
||||
func after_test():
|
||||
_metrics[__active_test_case].count_test_after_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_execute_3times(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 3):
|
||||
_metrics[__active_test_case].count_test()
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_execute_5times(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 5):
|
||||
_metrics[__active_test_case].count_test()
|
||||
pass
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
class_name TestSuiteInvalidParameterizedTests
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func test_no_parameters():
|
||||
assert_that(true).is_equal(true)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_success(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 12],
|
||||
[6, 7, 8, 21] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_failed(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 21] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_to_less_args(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_to_many_args(a: int, b :int, c :int, d :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_to_less_args_at_index_1(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_invalid_struct(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 6],
|
||||
["foo"],
|
||||
[6, 7, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_invalid_args(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 6],
|
||||
[3, "4", 11],
|
||||
[6, 7, 21] ]):
|
||||
pass
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
@warning_ignore('return_value_discarded')
|
||||
|
||||
|
||||
class TestCaseStatistics:
|
||||
var _testcase_before_called := 0
|
||||
var _testcase_after_called := 0
|
||||
var _test_called := 0
|
||||
var _expected_calls :int
|
||||
|
||||
func _init(expected_calls :int):
|
||||
_expected_calls = expected_calls
|
||||
|
||||
func count_test_before_test():
|
||||
_testcase_before_called +=1
|
||||
|
||||
func count_test_after_test():
|
||||
_testcase_after_called +=1
|
||||
|
||||
func count_test():
|
||||
_test_called += 1
|
||||
|
||||
|
||||
var _metrics = {
|
||||
"test_parameterized_2times" : TestCaseStatistics.new(2),
|
||||
"test_parameterized_5times" : TestCaseStatistics.new(5)
|
||||
}
|
||||
|
||||
var _before_called := 0
|
||||
var _after_called := 0
|
||||
|
||||
|
||||
func before():
|
||||
_before_called += 1
|
||||
|
||||
|
||||
func after():
|
||||
_after_called += 1
|
||||
assert_that(_before_called)\
|
||||
.override_failure_message("Expecting 'before' is called only one times")\
|
||||
.is_equal(1)
|
||||
assert_that(_after_called)\
|
||||
.override_failure_message("Expecting 'after' is called only one times")\
|
||||
.is_equal(1)
|
||||
|
||||
for test_case in _metrics.keys():
|
||||
var statistics := _metrics[test_case] as TestCaseStatistics
|
||||
assert_int(statistics._testcase_before_called)\
|
||||
.override_failure_message("Expect before_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_before_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._test_called)\
|
||||
.override_failure_message("Expect test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._test_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._testcase_after_called)\
|
||||
.override_failure_message("Expect after_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_after_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
|
||||
|
||||
func before_test():
|
||||
_metrics[__active_test_case].count_test_before_test()
|
||||
|
||||
|
||||
func after_test():
|
||||
_metrics[__active_test_case].count_test_after_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_2times(a: int, expected :bool, test_parameters := [
|
||||
[0, false],
|
||||
[1, true]]):
|
||||
|
||||
_metrics[__active_test_case].count_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_5times(a: int, expected :bool, test_parameters := [
|
||||
[0, false],
|
||||
[1, true],
|
||||
[0, false],
|
||||
[1, true],
|
||||
[1, true]]):
|
||||
|
||||
_metrics[__active_test_case].count_test()
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
@warning_ignore('return_value_discarded')
|
||||
|
||||
|
||||
class TestCaseStatistics:
|
||||
var _testcase_before_called := 0
|
||||
var _testcase_after_called := 0
|
||||
var _expected_testcase_before :int
|
||||
var _expected_testcase_after :int
|
||||
|
||||
func _init(testcase_before_calls := 0, testcase_after_calls := 0):
|
||||
_expected_testcase_before = testcase_before_calls
|
||||
_expected_testcase_after = testcase_after_calls
|
||||
|
||||
func count_test_before_test():
|
||||
_testcase_before_called +=1
|
||||
|
||||
func count_test_after_test():
|
||||
_testcase_after_called +=1
|
||||
|
||||
|
||||
var _metrics = {
|
||||
"test_parameterized_bool_value" : TestCaseStatistics.new(2, 2),
|
||||
"test_parameterized_int_values" : TestCaseStatistics.new(3, 3)
|
||||
}
|
||||
|
||||
var _before_called := 0
|
||||
var _after_called := 0
|
||||
|
||||
|
||||
func before():
|
||||
_before_called += 1
|
||||
|
||||
|
||||
func after():
|
||||
_after_called += 1
|
||||
assert_that(_before_called)\
|
||||
.override_failure_message("Expecting 'before' is called only one times")\
|
||||
.is_equal(1)
|
||||
assert_that(_after_called)\
|
||||
.override_failure_message("Expecting 'after' is called only one times")\
|
||||
.is_equal(1)
|
||||
|
||||
for test_case in _metrics.keys():
|
||||
var statistics := _metrics[test_case] as TestCaseStatistics
|
||||
assert_int(statistics._testcase_before_called)\
|
||||
.override_failure_message("Expect before_test called %s times but is %s for test case %s" % [statistics._expected_testcase_before, statistics._testcase_before_called, test_case])\
|
||||
.is_equal(statistics._expected_testcase_before)
|
||||
assert_int(statistics._testcase_after_called)\
|
||||
.override_failure_message("Expect after_test called %s times but is %s for test case %s" % [statistics._expected_testcase_after, statistics._testcase_after_called, test_case])\
|
||||
.is_equal(statistics._expected_testcase_after)
|
||||
|
||||
|
||||
func before_test():
|
||||
if _metrics.has(__active_test_case):
|
||||
_metrics[__active_test_case].count_test_before_test()
|
||||
|
||||
|
||||
func after_test():
|
||||
if _metrics.has(__active_test_case):
|
||||
_metrics[__active_test_case].count_test_after_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_bool_value(a: int, expected :bool, test_parameters := [
|
||||
[0, false],
|
||||
[1, true]]):
|
||||
|
||||
assert_that(bool(a)).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_int_values(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 12],
|
||||
[6, 7, 8, 21] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_int_values_fail(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 22] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_float_values(a: float, b :float, expected :float, test_parameters := [
|
||||
[2.2, 2.2, 4.4],
|
||||
[2.2, 2.3, 4.5],
|
||||
[3.3, 2.2, 5.5] ]):
|
||||
|
||||
assert_float(a+b).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_string_values(a: String, b :String, expected :String, test_parameters := [
|
||||
["2.2", "2.2", "2.22.2"],
|
||||
["foo", "bar", "foobar"],
|
||||
["a", "b", "ab"] ]):
|
||||
|
||||
assert_that(a+b).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_Vector2_values(a: Vector2, b :Vector2, expected :Vector2, test_parameters := [
|
||||
[Vector2.ONE, Vector2.ONE, Vector2(2, 2)],
|
||||
[Vector2.LEFT, Vector2.RIGHT, Vector2.ZERO],
|
||||
[Vector2.ZERO, Vector2.LEFT, Vector2.LEFT] ]):
|
||||
|
||||
assert_that(a+b).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_Vector3_values(a: Vector3, b :Vector3, expected :Vector3, test_parameters := [
|
||||
[Vector3.ONE, Vector3.ONE, Vector3(2, 2, 2)],
|
||||
[Vector3.LEFT, Vector3.RIGHT, Vector3.ZERO],
|
||||
[Vector3.ZERO, Vector3.LEFT, Vector3.LEFT] ]):
|
||||
|
||||
assert_that(a+b).is_equal(expected)
|
||||
|
||||
class TestObj extends Resource:
|
||||
var _value :String
|
||||
|
||||
func _init(value :String):
|
||||
_value = value
|
||||
|
||||
func _to_string() -> String:
|
||||
return _value
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_obj_values(a: Object, b :Object, expected :String, test_parameters := [
|
||||
[TestObj.new("abc"), TestObj.new("def"), "abcdef"]]):
|
||||
|
||||
assert_that(a.to_string()+b.to_string()).is_equal(expected)
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_dictionary_div_number_types(
|
||||
value : Dictionary,
|
||||
expected : Dictionary,
|
||||
test_parameters : Array = [
|
||||
[{ top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}, { top = 50, bottom = 50, left = 50, right = 50}],
|
||||
[{ top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}, { top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}],
|
||||
[{ top = 50, bottom = 50, left = 50, right = 50}, { top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}],
|
||||
[{ top = 50, bottom = 50, left = 50, right = 50}, { top = 50, bottom = 50, left = 50, right = 50}],
|
||||
]
|
||||
) -> void:
|
||||
assert_that(value).is_equal(expected)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
func is_skipped() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func before(do_skip=is_skipped(), skip_reason="do not run this"):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case1(timeout = 1000, do_skip=1==1, skip_reason="do not run this"):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case2(skip_reason="ignored"):
|
||||
pass
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
func before():
|
||||
pass
|
||||
|
||||
|
||||
func foo():
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue