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,42 @@
extends 'res://addons/gut/test.gd'
func test_passing_1():
pass_test("this passes")
func test_passing_2():
pass_test("this passes")
func test_passing_3():
pass_test("this passes")
func test_passing_4():
pass_test("this passes")
func test_passing_5():
pass_test("this passes")
func test_passing_6():
pass_test("this passes")
func test_passing_7():
pass_test("this passes")
func test_passing_8():
pass_test("this passes")
func test_passing_9():
pass_test("this passes")
func test_passing_10():
pass_test("this passes")
func test_passing_11():
pass_test("this passes")
func test_passing_12():
pass_test("this passes")
func test_passing_13():
pass_test("this passes")

View File

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

View File

@@ -0,0 +1,37 @@
extends GutTest
func test_this_is_only_a_test():
fail_test('but it is failing')
func test_duplicate_name():
pending('base level duplicate')
class TestPassingDupeNames:
extends GutTest
func test_duplicate_name():
pass_test('this one passes')
func test_duplicate_name_two():
pass_test('this also passes')
class TestBrokenDupedNames:
extends GutTest
func test_duplicate_name():
fail_test('this one fails')
func test_duplicate_name_two():
pending('this one is pending')
class TestInner:
extends GutTest
func test_something_cool():
pass_test('cool is cool')
func test_something_not_cool():
fail_test('failing is not cool')

View File

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

View File

@@ -0,0 +1,63 @@
extends GutTest
func test_passing_test():
pass_test('did it!')
func test_failing_test():
fail_test('did not do it!')
func test_generates_error():
gut.logger.error('This is a manual error')
pass_test('passing')
func test_generates_warning():
gut.logger.warn("This is a manual warning")
pass_test('passing')
func test_multiple_passing_asserts():
assert_eq(1, 1)
assert_eq(2, 2)
assert_eq('a', 'a')
func test_multiple_failing():
assert_ne(1, 1)
assert_ne(2, 2)
assert_ne('a', 'a')
func test_multiple_failing2():
assert_ne(1, 1)
assert_ne(2, 2)
func test_makes_orphan():
var orphan = Node2D.new()
assert_true(true)
func test_makes_an_info():
gut.logger.info("here is some info")
pass_test('info pass!')
func test_pending():
pending("this is pending")
func test_no_assert():
gut.p('this has no assert')
func test_this_makes_3_orphans():
var n1 = Node2D.new()
var n2 = Node2D.new()
var n3 = Node2D.new()
pass_test('passing')
func test_this_autofrees_2_of_3():
var n1 = add_child_autofree(Node2D.new())
var n2 = autofree(Node2D.new())
var n3 = Node2D.new()
pass_test('passing')
func test_fail_with_orphans():
var n1 = Node2D.new()
fail_test('failing with orphans')
func test_no_assert_and_orphans():
var n1 = Node2D.new()

View File

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

View File

@@ -0,0 +1,16 @@
extends GutTest
func test_all_passing(p = use_parameters([1, 2, 3, 4, 5, 6, 7, 8])):
assert_true(true, str('this always passes ', p))
func test_all_failing(p = use_parameters([1, 2, 3, 4, 5, 6, 7, 8])):
assert_true(false, str('this always passes ', p))
func test_some_failing(p = use_parameters([1, 2, 3, 4, 5, 6, 7, 8])):
assert_true(p%2 == 0, str('is even ', p))
func test_has_a_pending_in_middle(p = use_parameters([1, 2, 3, 4, 5, 6, 7, 8])):
if(p == 5):
pending("five is pending")
else:
assert_true(p != 3, str('this always passes ', p))

View File

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