Merge pull request #96229 from dalexeev/gds-replace-assert-in-tests
GDScript: Replace `assert()` with `Utils.check()` in tests
This commit is contained in:
commit
2e4c07bfe0
|
@ -3,14 +3,13 @@ const const_color: Color = 'red'
|
||||||
func func_color(arg_color: Color = 'blue') -> bool:
|
func func_color(arg_color: Color = 'blue') -> bool:
|
||||||
return arg_color == Color.BLUE
|
return arg_color == Color.BLUE
|
||||||
|
|
||||||
@warning_ignore("assert_always_true")
|
|
||||||
func test():
|
func test():
|
||||||
assert(const_color == Color.RED)
|
Utils.check(const_color == Color.RED)
|
||||||
|
|
||||||
assert(func_color() == true)
|
Utils.check(func_color() == true)
|
||||||
assert(func_color('blue') == true)
|
Utils.check(func_color('blue') == true)
|
||||||
|
|
||||||
var var_color: Color = 'green'
|
var var_color: Color = 'green'
|
||||||
assert(var_color == Color.GREEN)
|
Utils.check(var_color == Color.GREEN)
|
||||||
|
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -5,20 +5,19 @@ const const_float_cast: float = 76 as float
|
||||||
const const_packed_empty: PackedFloat64Array = []
|
const const_packed_empty: PackedFloat64Array = []
|
||||||
const const_packed_ints: PackedFloat64Array = [52]
|
const const_packed_ints: PackedFloat64Array = [52]
|
||||||
|
|
||||||
@warning_ignore("assert_always_true")
|
|
||||||
func test():
|
func test():
|
||||||
assert(typeof(const_float_int) == TYPE_FLOAT)
|
Utils.check(typeof(const_float_int) == TYPE_FLOAT)
|
||||||
assert(str(const_float_int) == '19')
|
Utils.check(str(const_float_int) == '19')
|
||||||
assert(typeof(const_float_plus) == TYPE_FLOAT)
|
Utils.check(typeof(const_float_plus) == TYPE_FLOAT)
|
||||||
assert(str(const_float_plus) == '34')
|
Utils.check(str(const_float_plus) == '34')
|
||||||
assert(typeof(const_float_cast) == TYPE_FLOAT)
|
Utils.check(typeof(const_float_cast) == TYPE_FLOAT)
|
||||||
assert(str(const_float_cast) == '76')
|
Utils.check(str(const_float_cast) == '76')
|
||||||
|
|
||||||
assert(typeof(const_packed_empty) == TYPE_PACKED_FLOAT64_ARRAY)
|
Utils.check(typeof(const_packed_empty) == TYPE_PACKED_FLOAT64_ARRAY)
|
||||||
assert(str(const_packed_empty) == '[]')
|
Utils.check(str(const_packed_empty) == '[]')
|
||||||
assert(typeof(const_packed_ints) == TYPE_PACKED_FLOAT64_ARRAY)
|
Utils.check(typeof(const_packed_ints) == TYPE_PACKED_FLOAT64_ARRAY)
|
||||||
assert(str(const_packed_ints) == '[52]')
|
Utils.check(str(const_packed_ints) == '[52]')
|
||||||
assert(typeof(const_packed_ints[0]) == TYPE_FLOAT)
|
Utils.check(typeof(const_packed_ints[0]) == TYPE_FLOAT)
|
||||||
assert(str(const_packed_ints[0]) == '52')
|
Utils.check(str(const_packed_ints[0]) == '52')
|
||||||
|
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -5,5 +5,5 @@ func test():
|
||||||
for value in range(E.E0, E.E3):
|
for value in range(E.E0, E.E3):
|
||||||
var inferable := value
|
var inferable := value
|
||||||
total += inferable
|
total += inferable
|
||||||
assert(total == 0 + 1 + 2)
|
Utils.check(total == 0 + 1 + 2)
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -2,8 +2,6 @@ class_name TestExportEnumAsDictionary
|
||||||
|
|
||||||
enum MyEnum {A, B, C}
|
enum MyEnum {A, B, C}
|
||||||
|
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
|
|
||||||
@export var test_1 = MyEnum
|
@export var test_1 = MyEnum
|
||||||
@export var test_2 = MyEnum.A
|
@export var test_2 = MyEnum.A
|
||||||
@export var test_3 := MyEnum
|
@export var test_3 := MyEnum
|
||||||
|
|
|
@ -3,5 +3,5 @@ func test():
|
||||||
var result := ''
|
var result := ''
|
||||||
for i in range(array.size(), 0, -1):
|
for i in range(array.size(), 0, -1):
|
||||||
result += str(array[i - 1])
|
result += str(array[i - 1])
|
||||||
assert(result == '963')
|
Utils.check(result == '963')
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -2,11 +2,11 @@ func test():
|
||||||
var instance := Parent.new()
|
var instance := Parent.new()
|
||||||
var result := instance.my_function(1)
|
var result := instance.my_function(1)
|
||||||
print(result)
|
print(result)
|
||||||
assert(result == 1)
|
Utils.check(result == 1)
|
||||||
instance = Child.new()
|
instance = Child.new()
|
||||||
result = instance.my_function(2)
|
result = instance.my_function(2)
|
||||||
print(result)
|
print(result)
|
||||||
assert(result == 0)
|
Utils.check(result == 0)
|
||||||
|
|
||||||
class Parent:
|
class Parent:
|
||||||
func my_function(par1: int) -> int:
|
func my_function(par1: int) -> int:
|
||||||
|
|
|
@ -8,27 +8,27 @@ func convert_var_array_to_packed() -> PackedStringArray: var array := ['79']; re
|
||||||
|
|
||||||
func test():
|
func test():
|
||||||
var converted_literal_int := convert_literal_int_to_float()
|
var converted_literal_int := convert_literal_int_to_float()
|
||||||
assert(typeof(converted_literal_int) == TYPE_FLOAT)
|
Utils.check(typeof(converted_literal_int) == TYPE_FLOAT)
|
||||||
assert(converted_literal_int == 76.0)
|
Utils.check(converted_literal_int == 76.0)
|
||||||
|
|
||||||
var converted_arg_int := convert_arg_int_to_float(36)
|
var converted_arg_int := convert_arg_int_to_float(36)
|
||||||
assert(typeof(converted_arg_int) == TYPE_FLOAT)
|
Utils.check(typeof(converted_arg_int) == TYPE_FLOAT)
|
||||||
assert(converted_arg_int == 36.0)
|
Utils.check(converted_arg_int == 36.0)
|
||||||
|
|
||||||
var converted_var_int := convert_var_int_to_float()
|
var converted_var_int := convert_var_int_to_float()
|
||||||
assert(typeof(converted_var_int) == TYPE_FLOAT)
|
Utils.check(typeof(converted_var_int) == TYPE_FLOAT)
|
||||||
assert(converted_var_int == 59.0)
|
Utils.check(converted_var_int == 59.0)
|
||||||
|
|
||||||
var converted_literal_array := convert_literal_array_to_packed()
|
var converted_literal_array := convert_literal_array_to_packed()
|
||||||
assert(typeof(converted_literal_array) == TYPE_PACKED_STRING_ARRAY)
|
Utils.check(typeof(converted_literal_array) == TYPE_PACKED_STRING_ARRAY)
|
||||||
assert(str(converted_literal_array) == '["46"]')
|
Utils.check(str(converted_literal_array) == '["46"]')
|
||||||
|
|
||||||
var converted_arg_array := convert_arg_array_to_packed(['91'])
|
var converted_arg_array := convert_arg_array_to_packed(['91'])
|
||||||
assert(typeof(converted_arg_array) == TYPE_PACKED_STRING_ARRAY)
|
Utils.check(typeof(converted_arg_array) == TYPE_PACKED_STRING_ARRAY)
|
||||||
assert(str(converted_arg_array) == '["91"]')
|
Utils.check(str(converted_arg_array) == '["91"]')
|
||||||
|
|
||||||
var converted_var_array := convert_var_array_to_packed()
|
var converted_var_array := convert_var_array_to_packed()
|
||||||
assert(typeof(converted_var_array) == TYPE_PACKED_STRING_ARRAY)
|
Utils.check(typeof(converted_var_array) == TYPE_PACKED_STRING_ARRAY)
|
||||||
assert(str(converted_var_array) == '["79"]')
|
Utils.check(str(converted_var_array) == '["79"]')
|
||||||
|
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -2,7 +2,7 @@ func test():
|
||||||
var left_hard_int := 1
|
var left_hard_int := 1
|
||||||
var right_hard_int := 2
|
var right_hard_int := 2
|
||||||
var result_hard_int := left_hard_int if true else right_hard_int
|
var result_hard_int := left_hard_int if true else right_hard_int
|
||||||
assert(result_hard_int == 1)
|
Utils.check(result_hard_int == 1)
|
||||||
|
|
||||||
@warning_ignore("inference_on_variant")
|
@warning_ignore("inference_on_variant")
|
||||||
var left_hard_variant := 1 as Variant
|
var left_hard_variant := 1 as Variant
|
||||||
|
@ -10,6 +10,6 @@ func test():
|
||||||
var right_hard_variant := 2.0 as Variant
|
var right_hard_variant := 2.0 as Variant
|
||||||
@warning_ignore("inference_on_variant")
|
@warning_ignore("inference_on_variant")
|
||||||
var result_hard_variant := left_hard_variant if true else right_hard_variant
|
var result_hard_variant := left_hard_variant if true else right_hard_variant
|
||||||
assert(result_hard_variant == 1)
|
Utils.check(result_hard_variant == 1)
|
||||||
|
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -4,124 +4,123 @@ class A extends RefCounted:
|
||||||
class B extends A:
|
class B extends A:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@warning_ignore("assert_always_true")
|
|
||||||
func test():
|
func test():
|
||||||
var builtin: Variant = 3
|
var builtin: Variant = 3
|
||||||
assert((builtin is Variant) == true)
|
Utils.check((builtin is Variant) == true)
|
||||||
assert((builtin is int) == true)
|
Utils.check((builtin is int) == true)
|
||||||
assert(is_instance_of(builtin, TYPE_INT) == true)
|
Utils.check(is_instance_of(builtin, TYPE_INT) == true)
|
||||||
assert((builtin is float) == false)
|
Utils.check((builtin is float) == false)
|
||||||
assert(is_instance_of(builtin, TYPE_FLOAT) == false)
|
Utils.check(is_instance_of(builtin, TYPE_FLOAT) == false)
|
||||||
|
|
||||||
const const_builtin: Variant = 3
|
const const_builtin: Variant = 3
|
||||||
assert((const_builtin is Variant) == true)
|
Utils.check((const_builtin is Variant) == true)
|
||||||
assert((const_builtin is int) == true)
|
Utils.check((const_builtin is int) == true)
|
||||||
assert(is_instance_of(const_builtin, TYPE_INT) == true)
|
Utils.check(is_instance_of(const_builtin, TYPE_INT) == true)
|
||||||
assert((const_builtin is float) == false)
|
Utils.check((const_builtin is float) == false)
|
||||||
assert(is_instance_of(const_builtin, TYPE_FLOAT) == false)
|
Utils.check(is_instance_of(const_builtin, TYPE_FLOAT) == false)
|
||||||
|
|
||||||
var int_array: Variant = [] as Array[int]
|
var int_array: Variant = [] as Array[int]
|
||||||
assert((int_array is Variant) == true)
|
Utils.check((int_array is Variant) == true)
|
||||||
assert((int_array is Array) == true)
|
Utils.check((int_array is Array) == true)
|
||||||
assert(is_instance_of(int_array, TYPE_ARRAY) == true)
|
Utils.check(is_instance_of(int_array, TYPE_ARRAY) == true)
|
||||||
assert((int_array is Array[int]) == true)
|
Utils.check((int_array is Array[int]) == true)
|
||||||
assert((int_array is Array[float]) == false)
|
Utils.check((int_array is Array[float]) == false)
|
||||||
assert((int_array is int) == false)
|
Utils.check((int_array is int) == false)
|
||||||
assert(is_instance_of(int_array, TYPE_INT) == false)
|
Utils.check(is_instance_of(int_array, TYPE_INT) == false)
|
||||||
|
|
||||||
var const_int_array: Variant = [] as Array[int]
|
var const_int_array: Variant = [] as Array[int]
|
||||||
assert((const_int_array is Variant) == true)
|
Utils.check((const_int_array is Variant) == true)
|
||||||
assert((const_int_array is Array) == true)
|
Utils.check((const_int_array is Array) == true)
|
||||||
assert(is_instance_of(const_int_array, TYPE_ARRAY) == true)
|
Utils.check(is_instance_of(const_int_array, TYPE_ARRAY) == true)
|
||||||
assert((const_int_array is Array[int]) == true)
|
Utils.check((const_int_array is Array[int]) == true)
|
||||||
assert((const_int_array is Array[float]) == false)
|
Utils.check((const_int_array is Array[float]) == false)
|
||||||
assert((const_int_array is int) == false)
|
Utils.check((const_int_array is int) == false)
|
||||||
assert(is_instance_of(const_int_array, TYPE_INT) == false)
|
Utils.check(is_instance_of(const_int_array, TYPE_INT) == false)
|
||||||
|
|
||||||
var b_array: Variant = [] as Array[B]
|
var b_array: Variant = [] as Array[B]
|
||||||
assert((b_array is Variant) == true)
|
Utils.check((b_array is Variant) == true)
|
||||||
assert((b_array is Array) == true)
|
Utils.check((b_array is Array) == true)
|
||||||
assert(is_instance_of(b_array, TYPE_ARRAY) == true)
|
Utils.check(is_instance_of(b_array, TYPE_ARRAY) == true)
|
||||||
assert((b_array is Array[B]) == true)
|
Utils.check((b_array is Array[B]) == true)
|
||||||
assert((b_array is Array[A]) == false)
|
Utils.check((b_array is Array[A]) == false)
|
||||||
assert((b_array is Array[int]) == false)
|
Utils.check((b_array is Array[int]) == false)
|
||||||
assert((b_array is int) == false)
|
Utils.check((b_array is int) == false)
|
||||||
assert(is_instance_of(b_array, TYPE_INT) == false)
|
Utils.check(is_instance_of(b_array, TYPE_INT) == false)
|
||||||
|
|
||||||
var const_b_array: Variant = [] as Array[B]
|
var const_b_array: Variant = [] as Array[B]
|
||||||
assert((const_b_array is Variant) == true)
|
Utils.check((const_b_array is Variant) == true)
|
||||||
assert((const_b_array is Array) == true)
|
Utils.check((const_b_array is Array) == true)
|
||||||
assert(is_instance_of(const_b_array, TYPE_ARRAY) == true)
|
Utils.check(is_instance_of(const_b_array, TYPE_ARRAY) == true)
|
||||||
assert((const_b_array is Array[B]) == true)
|
Utils.check((const_b_array is Array[B]) == true)
|
||||||
assert((const_b_array is Array[A]) == false)
|
Utils.check((const_b_array is Array[A]) == false)
|
||||||
assert((const_b_array is Array[int]) == false)
|
Utils.check((const_b_array is Array[int]) == false)
|
||||||
assert((const_b_array is int) == false)
|
Utils.check((const_b_array is int) == false)
|
||||||
assert(is_instance_of(const_b_array, TYPE_INT) == false)
|
Utils.check(is_instance_of(const_b_array, TYPE_INT) == false)
|
||||||
|
|
||||||
var native: Variant = RefCounted.new()
|
var native: Variant = RefCounted.new()
|
||||||
assert((native is Variant) == true)
|
Utils.check((native is Variant) == true)
|
||||||
assert((native is Object) == true)
|
Utils.check((native is Object) == true)
|
||||||
assert(is_instance_of(native, TYPE_OBJECT) == true)
|
Utils.check(is_instance_of(native, TYPE_OBJECT) == true)
|
||||||
assert(is_instance_of(native, Object) == true)
|
Utils.check(is_instance_of(native, Object) == true)
|
||||||
assert((native is RefCounted) == true)
|
Utils.check((native is RefCounted) == true)
|
||||||
assert(is_instance_of(native, RefCounted) == true)
|
Utils.check(is_instance_of(native, RefCounted) == true)
|
||||||
assert((native is Node) == false)
|
Utils.check((native is Node) == false)
|
||||||
assert(is_instance_of(native, Node) == false)
|
Utils.check(is_instance_of(native, Node) == false)
|
||||||
assert((native is int) == false)
|
Utils.check((native is int) == false)
|
||||||
assert(is_instance_of(native, TYPE_INT) == false)
|
Utils.check(is_instance_of(native, TYPE_INT) == false)
|
||||||
|
|
||||||
var a_script: Variant = A.new()
|
var a_script: Variant = A.new()
|
||||||
assert((a_script is Variant) == true)
|
Utils.check((a_script is Variant) == true)
|
||||||
assert((a_script is Object) == true)
|
Utils.check((a_script is Object) == true)
|
||||||
assert(is_instance_of(a_script, TYPE_OBJECT) == true)
|
Utils.check(is_instance_of(a_script, TYPE_OBJECT) == true)
|
||||||
assert(is_instance_of(a_script, Object) == true)
|
Utils.check(is_instance_of(a_script, Object) == true)
|
||||||
assert((a_script is RefCounted) == true)
|
Utils.check((a_script is RefCounted) == true)
|
||||||
assert(is_instance_of(a_script, RefCounted) == true)
|
Utils.check(is_instance_of(a_script, RefCounted) == true)
|
||||||
assert((a_script is A) == true)
|
Utils.check((a_script is A) == true)
|
||||||
assert(is_instance_of(a_script, A) == true)
|
Utils.check(is_instance_of(a_script, A) == true)
|
||||||
assert((a_script is B) == false)
|
Utils.check((a_script is B) == false)
|
||||||
assert(is_instance_of(a_script, B) == false)
|
Utils.check(is_instance_of(a_script, B) == false)
|
||||||
assert((a_script is Node) == false)
|
Utils.check((a_script is Node) == false)
|
||||||
assert(is_instance_of(a_script, Node) == false)
|
Utils.check(is_instance_of(a_script, Node) == false)
|
||||||
assert((a_script is int) == false)
|
Utils.check((a_script is int) == false)
|
||||||
assert(is_instance_of(a_script, TYPE_INT) == false)
|
Utils.check(is_instance_of(a_script, TYPE_INT) == false)
|
||||||
|
|
||||||
var b_script: Variant = B.new()
|
var b_script: Variant = B.new()
|
||||||
assert((b_script is Variant) == true)
|
Utils.check((b_script is Variant) == true)
|
||||||
assert((b_script is Object) == true)
|
Utils.check((b_script is Object) == true)
|
||||||
assert(is_instance_of(b_script, TYPE_OBJECT) == true)
|
Utils.check(is_instance_of(b_script, TYPE_OBJECT) == true)
|
||||||
assert(is_instance_of(b_script, Object) == true)
|
Utils.check(is_instance_of(b_script, Object) == true)
|
||||||
assert((b_script is RefCounted) == true)
|
Utils.check((b_script is RefCounted) == true)
|
||||||
assert(is_instance_of(b_script, RefCounted) == true)
|
Utils.check(is_instance_of(b_script, RefCounted) == true)
|
||||||
assert((b_script is A) == true)
|
Utils.check((b_script is A) == true)
|
||||||
assert(is_instance_of(b_script, A) == true)
|
Utils.check(is_instance_of(b_script, A) == true)
|
||||||
assert((b_script is B) == true)
|
Utils.check((b_script is B) == true)
|
||||||
assert(is_instance_of(b_script, B) == true)
|
Utils.check(is_instance_of(b_script, B) == true)
|
||||||
assert((b_script is Node) == false)
|
Utils.check((b_script is Node) == false)
|
||||||
assert(is_instance_of(b_script, Node) == false)
|
Utils.check(is_instance_of(b_script, Node) == false)
|
||||||
assert((b_script is int) == false)
|
Utils.check((b_script is int) == false)
|
||||||
assert(is_instance_of(b_script, TYPE_INT) == false)
|
Utils.check(is_instance_of(b_script, TYPE_INT) == false)
|
||||||
|
|
||||||
var var_null: Variant = null
|
var var_null: Variant = null
|
||||||
assert((var_null is Variant) == true)
|
Utils.check((var_null is Variant) == true)
|
||||||
assert((var_null is int) == false)
|
Utils.check((var_null is int) == false)
|
||||||
assert(is_instance_of(var_null, TYPE_INT) == false)
|
Utils.check(is_instance_of(var_null, TYPE_INT) == false)
|
||||||
assert((var_null is Object) == false)
|
Utils.check((var_null is Object) == false)
|
||||||
assert(is_instance_of(var_null, TYPE_OBJECT) == false)
|
Utils.check(is_instance_of(var_null, TYPE_OBJECT) == false)
|
||||||
assert((var_null is RefCounted) == false)
|
Utils.check((var_null is RefCounted) == false)
|
||||||
assert(is_instance_of(var_null, RefCounted) == false)
|
Utils.check(is_instance_of(var_null, RefCounted) == false)
|
||||||
assert((var_null is A) == false)
|
Utils.check((var_null is A) == false)
|
||||||
assert(is_instance_of(var_null, A) == false)
|
Utils.check(is_instance_of(var_null, A) == false)
|
||||||
|
|
||||||
const const_null: Variant = null
|
const const_null: Variant = null
|
||||||
assert((const_null is Variant) == true)
|
Utils.check((const_null is Variant) == true)
|
||||||
assert((const_null is int) == false)
|
Utils.check((const_null is int) == false)
|
||||||
assert(is_instance_of(const_null, TYPE_INT) == false)
|
Utils.check(is_instance_of(const_null, TYPE_INT) == false)
|
||||||
assert((const_null is Object) == false)
|
Utils.check((const_null is Object) == false)
|
||||||
assert(is_instance_of(const_null, TYPE_OBJECT) == false)
|
Utils.check(is_instance_of(const_null, TYPE_OBJECT) == false)
|
||||||
assert((const_null is RefCounted) == false)
|
Utils.check((const_null is RefCounted) == false)
|
||||||
assert(is_instance_of(const_null, RefCounted) == false)
|
Utils.check(is_instance_of(const_null, RefCounted) == false)
|
||||||
assert((const_null is A) == false)
|
Utils.check((const_null is A) == false)
|
||||||
assert(is_instance_of(const_null, A) == false)
|
Utils.check(is_instance_of(const_null, A) == false)
|
||||||
|
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -10,206 +10,205 @@ class Members:
|
||||||
var two: Array[int] = one
|
var two: Array[int] = one
|
||||||
|
|
||||||
func check_passing() -> bool:
|
func check_passing() -> bool:
|
||||||
assert(str(one) == '[104]')
|
Utils.check(str(one) == '[104]')
|
||||||
assert(str(two) == '[104]')
|
Utils.check(str(two) == '[104]')
|
||||||
two.push_back(582)
|
two.push_back(582)
|
||||||
assert(str(one) == '[104, 582]')
|
Utils.check(str(one) == '[104, 582]')
|
||||||
assert(str(two) == '[104, 582]')
|
Utils.check(str(two) == '[104, 582]')
|
||||||
two = [486]
|
two = [486]
|
||||||
assert(str(one) == '[104, 582]')
|
Utils.check(str(one) == '[104, 582]')
|
||||||
assert(str(two) == '[486]')
|
Utils.check(str(two) == '[486]')
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
@warning_ignore("unsafe_method_access")
|
@warning_ignore("unsafe_method_access")
|
||||||
@warning_ignore("assert_always_true")
|
|
||||||
@warning_ignore("return_value_discarded")
|
@warning_ignore("return_value_discarded")
|
||||||
func test():
|
func test():
|
||||||
var untyped_basic = [459]
|
var untyped_basic = [459]
|
||||||
assert(str(untyped_basic) == '[459]')
|
Utils.check(str(untyped_basic) == '[459]')
|
||||||
assert(untyped_basic.get_typed_builtin() == TYPE_NIL)
|
Utils.check(untyped_basic.get_typed_builtin() == TYPE_NIL)
|
||||||
|
|
||||||
var inferred_basic := [366]
|
var inferred_basic := [366]
|
||||||
assert(str(inferred_basic) == '[366]')
|
Utils.check(str(inferred_basic) == '[366]')
|
||||||
assert(inferred_basic.get_typed_builtin() == TYPE_NIL)
|
Utils.check(inferred_basic.get_typed_builtin() == TYPE_NIL)
|
||||||
|
|
||||||
var typed_basic: Array = [521]
|
var typed_basic: Array = [521]
|
||||||
assert(str(typed_basic) == '[521]')
|
Utils.check(str(typed_basic) == '[521]')
|
||||||
assert(typed_basic.get_typed_builtin() == TYPE_NIL)
|
Utils.check(typed_basic.get_typed_builtin() == TYPE_NIL)
|
||||||
|
|
||||||
|
|
||||||
var empty_floats: Array[float] = []
|
var empty_floats: Array[float] = []
|
||||||
assert(str(empty_floats) == '[]')
|
Utils.check(str(empty_floats) == '[]')
|
||||||
assert(empty_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(empty_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
untyped_basic = empty_floats
|
untyped_basic = empty_floats
|
||||||
assert(untyped_basic.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(untyped_basic.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
inferred_basic = empty_floats
|
inferred_basic = empty_floats
|
||||||
assert(inferred_basic.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(inferred_basic.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
typed_basic = empty_floats
|
typed_basic = empty_floats
|
||||||
assert(typed_basic.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(typed_basic.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
empty_floats.push_back(705.0)
|
empty_floats.push_back(705.0)
|
||||||
untyped_basic.push_back(430.0)
|
untyped_basic.push_back(430.0)
|
||||||
inferred_basic.push_back(263.0)
|
inferred_basic.push_back(263.0)
|
||||||
typed_basic.push_back(518.0)
|
typed_basic.push_back(518.0)
|
||||||
assert(str(empty_floats) == '[705, 430, 263, 518]')
|
Utils.check(str(empty_floats) == '[705, 430, 263, 518]')
|
||||||
assert(str(untyped_basic) == '[705, 430, 263, 518]')
|
Utils.check(str(untyped_basic) == '[705, 430, 263, 518]')
|
||||||
assert(str(inferred_basic) == '[705, 430, 263, 518]')
|
Utils.check(str(inferred_basic) == '[705, 430, 263, 518]')
|
||||||
assert(str(typed_basic) == '[705, 430, 263, 518]')
|
Utils.check(str(typed_basic) == '[705, 430, 263, 518]')
|
||||||
|
|
||||||
|
|
||||||
const constant_float := 950.0
|
const constant_float := 950.0
|
||||||
const constant_int := 170
|
const constant_int := 170
|
||||||
var typed_float := 954.0
|
var typed_float := 954.0
|
||||||
var filled_floats: Array[float] = [constant_float, constant_int, typed_float, empty_floats[1] + empty_floats[2]]
|
var filled_floats: Array[float] = [constant_float, constant_int, typed_float, empty_floats[1] + empty_floats[2]]
|
||||||
assert(str(filled_floats) == '[950, 170, 954, 693]')
|
Utils.check(str(filled_floats) == '[950, 170, 954, 693]')
|
||||||
assert(filled_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(filled_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
var casted_floats := [empty_floats[2] * 2] as Array[float]
|
var casted_floats := [empty_floats[2] * 2] as Array[float]
|
||||||
assert(str(casted_floats) == '[526]')
|
Utils.check(str(casted_floats) == '[526]')
|
||||||
assert(casted_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(casted_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
var returned_floats = (func () -> Array[float]: return [554]).call()
|
var returned_floats = (func () -> Array[float]: return [554]).call()
|
||||||
assert(str(returned_floats) == '[554]')
|
Utils.check(str(returned_floats) == '[554]')
|
||||||
assert(returned_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(returned_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
var passed_floats = floats_identity([663.0 if randf() > 0.5 else 663.0])
|
var passed_floats = floats_identity([663.0 if randf() > 0.5 else 663.0])
|
||||||
assert(str(passed_floats) == '[663]')
|
Utils.check(str(passed_floats) == '[663]')
|
||||||
assert(passed_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(passed_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
var default_floats = (func (floats: Array[float] = [364.0]): return floats).call()
|
var default_floats = (func (floats: Array[float] = [364.0]): return floats).call()
|
||||||
assert(str(default_floats) == '[364]')
|
Utils.check(str(default_floats) == '[364]')
|
||||||
assert(default_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(default_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
var typed_int := 556
|
var typed_int := 556
|
||||||
var converted_floats: Array[float] = [typed_int]
|
var converted_floats: Array[float] = [typed_int]
|
||||||
converted_floats.push_back(498)
|
converted_floats.push_back(498)
|
||||||
assert(str(converted_floats) == '[556, 498]')
|
Utils.check(str(converted_floats) == '[556, 498]')
|
||||||
assert(converted_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(converted_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
|
|
||||||
const constant_basic = [228]
|
const constant_basic = [228]
|
||||||
assert(str(constant_basic) == '[228]')
|
Utils.check(str(constant_basic) == '[228]')
|
||||||
assert(constant_basic.get_typed_builtin() == TYPE_NIL)
|
Utils.check(constant_basic.get_typed_builtin() == TYPE_NIL)
|
||||||
|
|
||||||
const constant_floats: Array[float] = [constant_float - constant_basic[0] - constant_int]
|
const constant_floats: Array[float] = [constant_float - constant_basic[0] - constant_int]
|
||||||
assert(str(constant_floats) == '[552]')
|
Utils.check(str(constant_floats) == '[552]')
|
||||||
assert(constant_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(constant_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
|
|
||||||
var source_floats: Array[float] = [999.74]
|
var source_floats: Array[float] = [999.74]
|
||||||
untyped_basic = source_floats
|
untyped_basic = source_floats
|
||||||
var destination_floats: Array[float] = untyped_basic
|
var destination_floats: Array[float] = untyped_basic
|
||||||
destination_floats[0] -= 0.74
|
destination_floats[0] -= 0.74
|
||||||
assert(str(source_floats) == '[999]')
|
Utils.check(str(source_floats) == '[999]')
|
||||||
assert(str(untyped_basic) == '[999]')
|
Utils.check(str(untyped_basic) == '[999]')
|
||||||
assert(str(destination_floats) == '[999]')
|
Utils.check(str(destination_floats) == '[999]')
|
||||||
assert(destination_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(destination_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
|
|
||||||
var duplicated_floats := empty_floats.duplicate().slice(2, 3)
|
var duplicated_floats := empty_floats.duplicate().slice(2, 3)
|
||||||
duplicated_floats[0] *= 3
|
duplicated_floats[0] *= 3
|
||||||
assert(str(duplicated_floats) == '[789]')
|
Utils.check(str(duplicated_floats) == '[789]')
|
||||||
assert(duplicated_floats.get_typed_builtin() == TYPE_FLOAT)
|
Utils.check(duplicated_floats.get_typed_builtin() == TYPE_FLOAT)
|
||||||
|
|
||||||
|
|
||||||
var b_objects: Array[B] = [B.new(), B.new() as A, null]
|
var b_objects: Array[B] = [B.new(), B.new() as A, null]
|
||||||
assert(b_objects.size() == 3)
|
Utils.check(b_objects.size() == 3)
|
||||||
assert(b_objects.get_typed_builtin() == TYPE_OBJECT)
|
Utils.check(b_objects.get_typed_builtin() == TYPE_OBJECT)
|
||||||
assert(b_objects.get_typed_script() == B)
|
Utils.check(b_objects.get_typed_script() == B)
|
||||||
|
|
||||||
var a_objects: Array[A] = [A.new(), B.new(), null, b_objects[0]]
|
var a_objects: Array[A] = [A.new(), B.new(), null, b_objects[0]]
|
||||||
assert(a_objects.size() == 4)
|
Utils.check(a_objects.size() == 4)
|
||||||
assert(a_objects.get_typed_builtin() == TYPE_OBJECT)
|
Utils.check(a_objects.get_typed_builtin() == TYPE_OBJECT)
|
||||||
assert(a_objects.get_typed_script() == A)
|
Utils.check(a_objects.get_typed_script() == A)
|
||||||
|
|
||||||
var a_passed = (func check_a_passing(p_objects: Array[A]): return p_objects.size()).call(a_objects)
|
var a_passed = (func check_a_passing(p_objects: Array[A]): return p_objects.size()).call(a_objects)
|
||||||
assert(a_passed == 4)
|
Utils.check(a_passed == 4)
|
||||||
|
|
||||||
var b_passed = (func check_b_passing(basic: Array): return basic[0] != null).call(b_objects)
|
var b_passed = (func check_b_passing(basic: Array): return basic[0] != null).call(b_objects)
|
||||||
assert(b_passed == true)
|
Utils.check(b_passed == true)
|
||||||
|
|
||||||
|
|
||||||
var empty_strings: Array[String] = []
|
var empty_strings: Array[String] = []
|
||||||
var empty_bools: Array[bool] = []
|
var empty_bools: Array[bool] = []
|
||||||
var empty_basic_one := []
|
var empty_basic_one := []
|
||||||
var empty_basic_two := []
|
var empty_basic_two := []
|
||||||
assert(empty_strings == empty_bools)
|
Utils.check(empty_strings == empty_bools)
|
||||||
assert(empty_basic_one == empty_basic_two)
|
Utils.check(empty_basic_one == empty_basic_two)
|
||||||
assert(empty_strings.hash() == empty_bools.hash())
|
Utils.check(empty_strings.hash() == empty_bools.hash())
|
||||||
assert(empty_basic_one.hash() == empty_basic_two.hash())
|
Utils.check(empty_basic_one.hash() == empty_basic_two.hash())
|
||||||
|
|
||||||
|
|
||||||
var assign_source: Array[int] = [527]
|
var assign_source: Array[int] = [527]
|
||||||
var assign_target: Array[int] = []
|
var assign_target: Array[int] = []
|
||||||
assign_target.assign(assign_source)
|
assign_target.assign(assign_source)
|
||||||
assert(str(assign_source) == '[527]')
|
Utils.check(str(assign_source) == '[527]')
|
||||||
assert(str(assign_target) == '[527]')
|
Utils.check(str(assign_target) == '[527]')
|
||||||
assign_source.push_back(657)
|
assign_source.push_back(657)
|
||||||
assert(str(assign_source) == '[527, 657]')
|
Utils.check(str(assign_source) == '[527, 657]')
|
||||||
assert(str(assign_target) == '[527]')
|
Utils.check(str(assign_target) == '[527]')
|
||||||
|
|
||||||
|
|
||||||
var defaults_passed = (func check_defaults_passing(one: Array[int] = [], two := one):
|
var defaults_passed = (func check_defaults_passing(one: Array[int] = [], two := one):
|
||||||
one.push_back(887)
|
one.push_back(887)
|
||||||
two.push_back(198)
|
two.push_back(198)
|
||||||
assert(str(one) == '[887, 198]')
|
Utils.check(str(one) == '[887, 198]')
|
||||||
assert(str(two) == '[887, 198]')
|
Utils.check(str(two) == '[887, 198]')
|
||||||
two = [130]
|
two = [130]
|
||||||
assert(str(one) == '[887, 198]')
|
Utils.check(str(one) == '[887, 198]')
|
||||||
assert(str(two) == '[130]')
|
Utils.check(str(two) == '[130]')
|
||||||
return true
|
return true
|
||||||
).call()
|
).call()
|
||||||
assert(defaults_passed == true)
|
Utils.check(defaults_passed == true)
|
||||||
|
|
||||||
|
|
||||||
var members := Members.new()
|
var members := Members.new()
|
||||||
var members_passed := members.check_passing()
|
var members_passed := members.check_passing()
|
||||||
assert(members_passed == true)
|
Utils.check(members_passed == true)
|
||||||
|
|
||||||
|
|
||||||
var resized_basic: Array = []
|
var resized_basic: Array = []
|
||||||
resized_basic.resize(1)
|
resized_basic.resize(1)
|
||||||
assert(typeof(resized_basic[0]) == TYPE_NIL)
|
Utils.check(typeof(resized_basic[0]) == TYPE_NIL)
|
||||||
assert(resized_basic[0] == null)
|
Utils.check(resized_basic[0] == null)
|
||||||
|
|
||||||
var resized_ints: Array[int] = []
|
var resized_ints: Array[int] = []
|
||||||
resized_ints.resize(1)
|
resized_ints.resize(1)
|
||||||
assert(typeof(resized_ints[0]) == TYPE_INT)
|
Utils.check(typeof(resized_ints[0]) == TYPE_INT)
|
||||||
assert(resized_ints[0] == 0)
|
Utils.check(resized_ints[0] == 0)
|
||||||
|
|
||||||
var resized_arrays: Array[Array] = []
|
var resized_arrays: Array[Array] = []
|
||||||
resized_arrays.resize(1)
|
resized_arrays.resize(1)
|
||||||
assert(typeof(resized_arrays[0]) == TYPE_ARRAY)
|
Utils.check(typeof(resized_arrays[0]) == TYPE_ARRAY)
|
||||||
resized_arrays[0].resize(1)
|
resized_arrays[0].resize(1)
|
||||||
resized_arrays[0][0] = 523
|
resized_arrays[0][0] = 523
|
||||||
assert(str(resized_arrays) == '[[523]]')
|
Utils.check(str(resized_arrays) == '[[523]]')
|
||||||
|
|
||||||
var resized_objects: Array[Object] = []
|
var resized_objects: Array[Object] = []
|
||||||
resized_objects.resize(1)
|
resized_objects.resize(1)
|
||||||
assert(typeof(resized_objects[0]) == TYPE_NIL)
|
Utils.check(typeof(resized_objects[0]) == TYPE_NIL)
|
||||||
assert(resized_objects[0] == null)
|
Utils.check(resized_objects[0] == null)
|
||||||
|
|
||||||
|
|
||||||
var typed_enums: Array[E] = []
|
var typed_enums: Array[E] = []
|
||||||
typed_enums.resize(1)
|
typed_enums.resize(1)
|
||||||
assert(str(typed_enums) == '[0]')
|
Utils.check(str(typed_enums) == '[0]')
|
||||||
typed_enums[0] = E.E0
|
typed_enums[0] = E.E0
|
||||||
assert(str(typed_enums) == '[391]')
|
Utils.check(str(typed_enums) == '[391]')
|
||||||
assert(typed_enums.get_typed_builtin() == TYPE_INT)
|
Utils.check(typed_enums.get_typed_builtin() == TYPE_INT)
|
||||||
|
|
||||||
const const_enums: Array[E] = []
|
const const_enums: Array[E] = []
|
||||||
assert(const_enums.get_typed_builtin() == TYPE_INT)
|
Utils.check(const_enums.get_typed_builtin() == TYPE_INT)
|
||||||
assert(const_enums.get_typed_class_name() == &'')
|
Utils.check(const_enums.get_typed_class_name() == &'')
|
||||||
|
|
||||||
|
|
||||||
var a := A.new()
|
var a := A.new()
|
||||||
var typed_natives: Array[RefCounted] = [a]
|
var typed_natives: Array[RefCounted] = [a]
|
||||||
var typed_scripts = Array(typed_natives, TYPE_OBJECT, "RefCounted", A)
|
var typed_scripts = Array(typed_natives, TYPE_OBJECT, "RefCounted", A)
|
||||||
assert(typed_scripts[0] == a)
|
Utils.check(typed_scripts[0] == a)
|
||||||
|
|
||||||
|
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
|
|
||||||
@export_enum("A", "B", "C") var test_1
|
@export_enum("A", "B", "C") var test_1
|
||||||
@export_enum("A", "B", "C",) var test_2
|
@export_enum("A", "B", "C",) var test_2
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ func test():
|
||||||
test_instance.number = 42
|
test_instance.number = 42
|
||||||
|
|
||||||
var test_sub = TestSub.new()
|
var test_sub = TestSub.new()
|
||||||
assert(test_sub.number == 25) # From Test.
|
Utils.check(test_sub.number == 25) # From Test.
|
||||||
assert(test_sub.other_string == "bye") # From TestSub.
|
Utils.check(test_sub.other_string == "bye") # From TestSub.
|
||||||
|
|
||||||
var _test_constructor = TestConstructor.new()
|
var _test_constructor = TestConstructor.new()
|
||||||
_test_constructor = TestConstructor.new(500)
|
_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: Array[String]
|
||||||
@export_dir var test_dir_packed: PackedStringArray
|
@export_dir var test_dir_packed: PackedStringArray
|
||||||
@export_file var test_file: Array[String]
|
@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", "Green", "Blue") var test_untyped
|
||||||
@export_enum("Red:10", "Green:20", "Blue:30") var test_with_values
|
@export_enum("Red:10", "Green:20", "Blue:30") var test_with_values
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
class_name ExportVariableTest
|
class_name ExportVariableTest
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
const PreloadedGlobalClass = preload("./export_variable_global.notest.gd")
|
const PreloadedGlobalClass = preload("./export_variable_global.notest.gd")
|
||||||
const PreloadedUnnamedClass = preload("./export_variable_unnamed.notest.gd")
|
const PreloadedUnnamedClass = preload("./export_variable_unnamed.notest.gd")
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,5 @@ func test():
|
||||||
j_string += str(j)
|
j_string += str(j)
|
||||||
return j_string
|
return j_string
|
||||||
i_string += lambda.call()
|
i_string += lambda.call()
|
||||||
assert(i_string == '0202')
|
Utils.check(i_string == '0202')
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
func test():
|
func test():
|
||||||
# The assertions below should all evaluate to `true` for this test to pass.
|
# The checks below should all evaluate to `true` for this test to pass.
|
||||||
assert(true)
|
Utils.check(true)
|
||||||
assert(not false)
|
Utils.check(not false)
|
||||||
assert(500)
|
Utils.check(500)
|
||||||
assert(not 0)
|
Utils.check(not 0)
|
||||||
assert(500.5)
|
Utils.check(500.5)
|
||||||
assert(not 0.0)
|
Utils.check(not 0.0)
|
||||||
assert("non-empty string")
|
Utils.check("non-empty string")
|
||||||
assert(["non-empty array"])
|
Utils.check(["non-empty array"])
|
||||||
assert({"non-empty": "dictionary"})
|
Utils.check({"non-empty": "dictionary"})
|
||||||
assert(Vector2(1, 0))
|
Utils.check(Vector2(1, 0))
|
||||||
assert(Vector2i(-1, -1))
|
Utils.check(Vector2i(-1, -1))
|
||||||
assert(Vector3(0, 0, 0.0001))
|
Utils.check(Vector3(0, 0, 0.0001))
|
||||||
assert(Vector3i(0, 0, 10000))
|
Utils.check(Vector3i(0, 0, 10000))
|
||||||
|
|
||||||
# Zero position is `true` only if the Rect2's size is non-zero.
|
# 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.
|
# 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.
|
# 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.
|
# 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`.
|
# 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
|
GDTEST_OK
|
||||||
>> WARNING
|
ok
|
||||||
>> 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.
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ func test():
|
||||||
print("String in Array[StringName]: ", "abc" in stringname_array)
|
print("String in Array[StringName]: ", "abc" in stringname_array)
|
||||||
|
|
||||||
var packed_string_array: PackedStringArray = []
|
var packed_string_array: PackedStringArray = []
|
||||||
assert(!packed_string_array.push_back("abc"))
|
Utils.check(!packed_string_array.push_back("abc"))
|
||||||
print("StringName in PackedStringArray: ", &"abc" in packed_string_array)
|
print("StringName in PackedStringArray: ", &"abc" in packed_string_array)
|
||||||
|
|
||||||
string_array.push_back("abc")
|
string_array.push_back("abc")
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const array: Array = [0]
|
const array: Array = [0]
|
||||||
const dictionary := {1: 2}
|
const dictionary := {1: 2}
|
||||||
|
|
||||||
@warning_ignore("assert_always_true")
|
|
||||||
func test():
|
func test():
|
||||||
assert(array.is_read_only() == true)
|
Utils.check(array.is_read_only() == true)
|
||||||
assert(str(array) == '[0]')
|
Utils.check(str(array) == '[0]')
|
||||||
assert(dictionary.is_read_only() == true)
|
Utils.check(dictionary.is_read_only() == true)
|
||||||
assert(str(dictionary) == '{ 1: 2 }')
|
Utils.check(str(dictionary) == '{ 1: 2 }')
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -2,8 +2,8 @@ class Foo extends Node:
|
||||||
func _init():
|
func _init():
|
||||||
name = 'f'
|
name = 'f'
|
||||||
var string: String = name
|
var string: String = name
|
||||||
assert(typeof(string) == TYPE_STRING)
|
Utils.check(typeof(string) == TYPE_STRING)
|
||||||
assert(string == 'f')
|
Utils.check(string == 'f')
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
||||||
func test():
|
func test():
|
||||||
|
|
|
@ -6,15 +6,15 @@ extends Node
|
||||||
@onready var later_untyped = [1]
|
@onready var later_untyped = [1]
|
||||||
|
|
||||||
func test():
|
func test():
|
||||||
assert(typeof(later_inferred) == TYPE_ARRAY)
|
Utils.check(typeof(later_inferred) == TYPE_ARRAY)
|
||||||
assert(later_inferred.size() == 0)
|
Utils.check(later_inferred.size() == 0)
|
||||||
|
|
||||||
assert(typeof(later_static) == TYPE_ARRAY)
|
Utils.check(typeof(later_static) == TYPE_ARRAY)
|
||||||
assert(later_static.size() == 0)
|
Utils.check(later_static.size() == 0)
|
||||||
|
|
||||||
assert(typeof(later_static_with_init) == TYPE_ARRAY)
|
Utils.check(typeof(later_static_with_init) == TYPE_ARRAY)
|
||||||
assert(later_static_with_init.size() == 0)
|
Utils.check(later_static_with_init.size() == 0)
|
||||||
|
|
||||||
assert(typeof(later_untyped) == TYPE_NIL)
|
Utils.check(typeof(later_untyped) == TYPE_NIL)
|
||||||
|
|
||||||
print("ok")
|
print("ok")
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
|
|
||||||
# GH-73843
|
# GH-73843
|
||||||
@export_group("Resource")
|
@export_group("Resource")
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ func test():
|
||||||
0 when side_effect():
|
0 when side_effect():
|
||||||
print("will run the side effect call, but not this")
|
print("will run the side effect call, but not this")
|
||||||
_:
|
_:
|
||||||
assert(global == 1)
|
Utils.check(global == 1)
|
||||||
print("side effect only ran once")
|
print("side effect only ran once")
|
||||||
|
|
||||||
func side_effect():
|
func side_effect():
|
||||||
|
|
|
@ -5,8 +5,6 @@ class MyClass:
|
||||||
|
|
||||||
enum MyEnum {}
|
enum MyEnum {}
|
||||||
|
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
|
|
||||||
static var test_static_var_untyped
|
static var test_static_var_untyped
|
||||||
static var test_static_var_weak_null = null
|
static var test_static_var_weak_null = null
|
||||||
static var test_static_var_weak_int = 1
|
static var test_static_var_weak_int = 1
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# GH-82169
|
# GH-82169
|
||||||
|
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
|
|
||||||
class A:
|
class A:
|
||||||
static var test_static_var_a1
|
static var test_static_var_a1
|
||||||
static var test_static_var_a2
|
static var test_static_var_a2
|
||||||
|
|
|
@ -3,7 +3,6 @@ class MyClass:
|
||||||
|
|
||||||
enum MyEnum {A, B, C}
|
enum MyEnum {A, B, C}
|
||||||
|
|
||||||
const Utils = preload("../../utils.notest.gd")
|
|
||||||
const Other = preload("./metatypes.notest.gd")
|
const Other = preload("./metatypes.notest.gd")
|
||||||
|
|
||||||
var test_native := JSON
|
var test_native := JSON
|
||||||
|
|
|
@ -6,6 +6,6 @@ class MyObj:
|
||||||
func test():
|
func test():
|
||||||
var obj_1 = MyObj.new()
|
var obj_1 = MyObj.new()
|
||||||
var obj_2 = MyObj.new()
|
var obj_2 = MyObj.new()
|
||||||
assert(obj_2.get_reference_count() == 1)
|
Utils.check(obj_2.get_reference_count() == 1)
|
||||||
obj_1.set(&"obj", obj_2)
|
obj_1.set(&"obj", obj_2)
|
||||||
assert(obj_2.get_reference_count() == 1)
|
Utils.check(obj_2.get_reference_count() == 1)
|
||||||
|
|
|
@ -12,4 +12,4 @@ func test() -> void:
|
||||||
node1.add_child(node2)
|
node1.add_child(node2)
|
||||||
add_child(node3)
|
add_child(node3)
|
||||||
|
|
||||||
assert(get_node("_/Child") == $_/Child)
|
Utils.check(get_node("_/Child") == $_/Child)
|
||||||
|
|
|
@ -14,33 +14,33 @@ func test():
|
||||||
func test_construct(v, f):
|
func test_construct(v, f):
|
||||||
@warning_ignore("unsafe_call_argument")
|
@warning_ignore("unsafe_call_argument")
|
||||||
Vector2(v, v) # Built-in type construct.
|
Vector2(v, v) # Built-in type construct.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
||||||
func test_utility(v, f):
|
func test_utility(v, f):
|
||||||
abs(v) # Utility function.
|
abs(v) # Utility function.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
||||||
func test_builtin_call(v, f):
|
func test_builtin_call(v, f):
|
||||||
@warning_ignore("unsafe_method_access")
|
@warning_ignore("unsafe_method_access")
|
||||||
v.angle() # Built-in method call.
|
v.angle() # Built-in method call.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
||||||
func test_builtin_call_validated(v: Vector2, f):
|
func test_builtin_call_validated(v: Vector2, f):
|
||||||
@warning_ignore("return_value_discarded")
|
@warning_ignore("return_value_discarded")
|
||||||
v.abs() # Built-in method call validated.
|
v.abs() # Built-in method call validated.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
||||||
func test_object_call(v, f):
|
func test_object_call(v, f):
|
||||||
@warning_ignore("unsafe_method_access")
|
@warning_ignore("unsafe_method_access")
|
||||||
v.get_reference_count() # Native type method call.
|
v.get_reference_count() # Native type method call.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
||||||
func test_object_call_method_bind(v: Resource, f):
|
func test_object_call_method_bind(v: Resource, f):
|
||||||
@warning_ignore("return_value_discarded")
|
@warning_ignore("return_value_discarded")
|
||||||
v.duplicate() # Native type method call with MethodBind.
|
v.duplicate() # Native type method call with MethodBind.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
||||||
func test_object_call_method_bind_validated(v: RefCounted, f):
|
func test_object_call_method_bind_validated(v: RefCounted, f):
|
||||||
@warning_ignore("return_value_discarded")
|
@warning_ignore("return_value_discarded")
|
||||||
v.get_reference_count() # Native type method call with validated MethodBind.
|
v.get_reference_count() # Native type method call with validated MethodBind.
|
||||||
assert(not f) # Test unary operator reading from `nil`.
|
Utils.check(not f) # Test unary operator reading from `nil`.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
func test():
|
func test():
|
||||||
var untyped: Variant = 32
|
var untyped: Variant = 32
|
||||||
var typed: Array[int] = [untyped]
|
var typed: Array[int] = [untyped]
|
||||||
assert(typed.get_typed_builtin() == TYPE_INT)
|
Utils.check(typed.get_typed_builtin() == TYPE_INT)
|
||||||
assert(str(typed) == '[32]')
|
Utils.check(str(typed) == '[32]')
|
||||||
print('ok')
|
print('ok')
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
class_name Utils
|
||||||
|
|
||||||
|
|
||||||
|
# `assert()` is not evaluated in non-debug builds. Do not use `assert()`
|
||||||
|
# for anything other than testing the `assert()` itself.
|
||||||
|
static func check(condition: Variant) -> void:
|
||||||
|
if not condition:
|
||||||
|
printerr("Check failed.")
|
||||||
|
|
||||||
|
|
||||||
static func get_type(property: Dictionary, is_return: bool = false) -> String:
|
static func get_type(property: Dictionary, is_return: bool = false) -> String:
|
||||||
match property.type:
|
match property.type:
|
||||||
TYPE_NIL:
|
TYPE_NIL:
|
||||||
|
@ -46,7 +56,7 @@ static func get_human_readable_hint_string(property: Dictionary) -> String:
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
if not hint_string.contains(":"):
|
if not hint_string.contains(":"):
|
||||||
push_error("Invalid PROPERTY_HINT_TYPE_STRING format.")
|
printerr("Invalid PROPERTY_HINT_TYPE_STRING format.")
|
||||||
var elem_type_hint: String = hint_string.get_slice(":", 0)
|
var elem_type_hint: String = hint_string.get_slice(":", 0)
|
||||||
hint_string = hint_string.substr(elem_type_hint.length() + 1)
|
hint_string = hint_string.substr(elem_type_hint.length() + 1)
|
||||||
|
|
||||||
|
@ -58,7 +68,7 @@ static func get_human_readable_hint_string(property: Dictionary) -> String:
|
||||||
type_hint_prefixes += "<%s>:" % type_string(elem_type)
|
type_hint_prefixes += "<%s>:" % type_string(elem_type)
|
||||||
else:
|
else:
|
||||||
if elem_type_hint.count("/") != 1:
|
if elem_type_hint.count("/") != 1:
|
||||||
push_error("Invalid PROPERTY_HINT_TYPE_STRING format.")
|
printerr("Invalid PROPERTY_HINT_TYPE_STRING format.")
|
||||||
elem_type = elem_type_hint.get_slice("/", 0).to_int()
|
elem_type = elem_type_hint.get_slice("/", 0).to_int()
|
||||||
elem_hint = elem_type_hint.get_slice("/", 1).to_int()
|
elem_hint = elem_type_hint.get_slice("/", 1).to_int()
|
||||||
type_hint_prefixes += "<%s>/<%s>:" % [
|
type_hint_prefixes += "<%s>/<%s>:" % [
|
||||||
|
@ -188,7 +198,7 @@ static func get_property_hint_name(hint: PropertyHint) -> String:
|
||||||
return "PROPERTY_HINT_HIDE_QUATERNION_EDIT"
|
return "PROPERTY_HINT_HIDE_QUATERNION_EDIT"
|
||||||
PROPERTY_HINT_PASSWORD:
|
PROPERTY_HINT_PASSWORD:
|
||||||
return "PROPERTY_HINT_PASSWORD"
|
return "PROPERTY_HINT_PASSWORD"
|
||||||
push_error("Argument `hint` is invalid. Use `PROPERTY_HINT_*` constants.")
|
printerr("Argument `hint` is invalid. Use `PROPERTY_HINT_*` constants.")
|
||||||
return "<invalid hint>"
|
return "<invalid hint>"
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,7 +250,7 @@ static func get_property_usage_string(usage: int) -> String:
|
||||||
usage &= ~flag[0]
|
usage &= ~flag[0]
|
||||||
|
|
||||||
if usage != PROPERTY_USAGE_NONE:
|
if usage != PROPERTY_USAGE_NONE:
|
||||||
push_error("Argument `usage` is invalid. Use `PROPERTY_USAGE_*` constants.")
|
printerr("Argument `usage` is invalid. Use `PROPERTY_USAGE_*` constants.")
|
||||||
return "<invalid usage flags>"
|
return "<invalid usage flags>"
|
||||||
|
|
||||||
return result.left(-1)
|
return result.left(-1)
|
||||||
|
|
Loading…
Reference in New Issue