You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
GDScript: Replace assert() with Utils.check() in tests
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
extends Node
|
||||
|
||||
const Utils = preload("../../utils.notest.gd")
|
||||
|
||||
@export_enum("A", "B", "C") var test_1
|
||||
@export_enum("A", "B", "C",) var test_2
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ func test():
|
||||
test_instance.number = 42
|
||||
|
||||
var test_sub = TestSub.new()
|
||||
assert(test_sub.number == 25) # From Test.
|
||||
assert(test_sub.other_string == "bye") # From TestSub.
|
||||
Utils.check(test_sub.number == 25) # From Test.
|
||||
Utils.check(test_sub.other_string == "bye") # From TestSub.
|
||||
|
||||
var _test_constructor = TestConstructor.new()
|
||||
_test_constructor = TestConstructor.new(500)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const Utils = preload("../../utils.notest.gd")
|
||||
|
||||
@export_dir var test_dir: Array[String]
|
||||
@export_dir var test_dir_packed: PackedStringArray
|
||||
@export_file var test_file: Array[String]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const Utils = preload("../../utils.notest.gd")
|
||||
|
||||
@export_enum("Red", "Green", "Blue") var test_untyped
|
||||
@export_enum("Red:10", "Green:20", "Blue:30") var test_with_values
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class_name ExportVariableTest
|
||||
extends Node
|
||||
|
||||
const Utils = preload("../../utils.notest.gd")
|
||||
const PreloadedGlobalClass = preload("./export_variable_global.notest.gd")
|
||||
const PreloadedUnnamedClass = preload("./export_variable_unnamed.notest.gd")
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ func test():
|
||||
j_string += str(j)
|
||||
return j_string
|
||||
i_string += lambda.call()
|
||||
assert(i_string == '0202')
|
||||
Utils.check(i_string == '0202')
|
||||
print('ok')
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
func test():
|
||||
# The assertions below should all evaluate to `true` for this test to pass.
|
||||
assert(true)
|
||||
assert(not false)
|
||||
assert(500)
|
||||
assert(not 0)
|
||||
assert(500.5)
|
||||
assert(not 0.0)
|
||||
assert("non-empty string")
|
||||
assert(["non-empty array"])
|
||||
assert({"non-empty": "dictionary"})
|
||||
assert(Vector2(1, 0))
|
||||
assert(Vector2i(-1, -1))
|
||||
assert(Vector3(0, 0, 0.0001))
|
||||
assert(Vector3i(0, 0, 10000))
|
||||
# The checks below should all evaluate to `true` for this test to pass.
|
||||
Utils.check(true)
|
||||
Utils.check(not false)
|
||||
Utils.check(500)
|
||||
Utils.check(not 0)
|
||||
Utils.check(500.5)
|
||||
Utils.check(not 0.0)
|
||||
Utils.check("non-empty string")
|
||||
Utils.check(["non-empty array"])
|
||||
Utils.check({"non-empty": "dictionary"})
|
||||
Utils.check(Vector2(1, 0))
|
||||
Utils.check(Vector2i(-1, -1))
|
||||
Utils.check(Vector3(0, 0, 0.0001))
|
||||
Utils.check(Vector3i(0, 0, 10000))
|
||||
|
||||
# Zero position is `true` only if the Rect2's size is non-zero.
|
||||
assert(Rect2(0, 0, 0, 1))
|
||||
Utils.check(Rect2(0, 0, 0, 1))
|
||||
|
||||
# Zero size is `true` only if the position is non-zero.
|
||||
assert(Rect2(1, 1, 0, 0))
|
||||
Utils.check(Rect2(1, 1, 0, 0))
|
||||
|
||||
# Zero position is `true` only if the Rect2's size is non-zero.
|
||||
assert(Rect2i(0, 0, 0, 1))
|
||||
Utils.check(Rect2i(0, 0, 0, 1))
|
||||
|
||||
# Zero size is `true` only if the position is non-zero.
|
||||
assert(Rect2i(1, 1, 0, 0))
|
||||
Utils.check(Rect2i(1, 1, 0, 0))
|
||||
|
||||
# A fully black color is only truthy if its alpha component is not equal to `1`.
|
||||
assert(Color(0, 0, 0, 0.5))
|
||||
Utils.check(Color(0, 0, 0, 0.5))
|
||||
|
||||
print("ok")
|
||||
|
||||
@@ -1,65 +1,2 @@
|
||||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 3
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 4
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 5
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 6
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 7
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 8
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 9
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 12
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 13
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 14
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 15
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 18
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 21
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 24
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 27
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
>> WARNING
|
||||
>> Line: 30
|
||||
>> ASSERT_ALWAYS_TRUE
|
||||
>> Assert statement is redundant because the expression is always true.
|
||||
ok
|
||||
|
||||
Reference in New Issue
Block a user