initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
extends Node
|
||||
|
||||
@onready var shorthand = $Node
|
||||
@onready var call_no_cast = get_node(^"Node")
|
||||
@onready var shorthand_with_cast = $Node as Node
|
||||
@onready var call_with_cast = get_node(^"Node") as Node
|
||||
|
||||
func _init():
|
||||
var node := Node.new()
|
||||
node.name = "Node"
|
||||
add_child(node)
|
||||
|
||||
func test():
|
||||
# Those are expected to be `null` since `_ready()` is never called on tests.
|
||||
prints("shorthand", shorthand)
|
||||
prints("call_no_cast", call_no_cast)
|
||||
prints("shorthand_with_cast", shorthand_with_cast)
|
||||
prints("call_with_cast", call_with_cast)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
shorthand <null>
|
||||
call_no_cast <null>
|
||||
shorthand_with_cast <null>
|
||||
call_with_cast <null>
|
@@ -0,0 +1,20 @@
|
||||
func test():
|
||||
return_call()
|
||||
return_nothing()
|
||||
return_side_effect()
|
||||
var r = return_side_effect.call() # Untyped call to check return value.
|
||||
prints(r, typeof(r) == TYPE_NIL)
|
||||
print("end")
|
||||
|
||||
func side_effect(v):
|
||||
print("effect")
|
||||
return v
|
||||
|
||||
func return_call() -> void:
|
||||
return print("hello")
|
||||
|
||||
func return_nothing() -> void:
|
||||
return
|
||||
|
||||
func return_side_effect() -> void:
|
||||
return side_effect("x")
|
@@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
~~ WARNING at line 20: (UNSAFE_VOID_RETURN) The method "return_side_effect()" returns "void" but it's trying to return a call to "side_effect()" that can't be ensured to also be "void".
|
||||
hello
|
||||
effect
|
||||
effect
|
||||
<null> true
|
||||
end
|
@@ -0,0 +1,10 @@
|
||||
const BEFORE = 1
|
||||
|
||||
@export_range(-10, 10) var a = 0
|
||||
@export_range(1 + 2, absi(-10) + 1) var b = 5
|
||||
@export_range(BEFORE + 1, BEFORE + AFTER + 1) var c = 5
|
||||
|
||||
const AFTER = 10
|
||||
|
||||
func test():
|
||||
pass
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,15 @@
|
||||
|
||||
var m_string_array: Array[String] = [&"abc"]
|
||||
var m_stringname_array: Array[StringName] = ["abc"]
|
||||
|
||||
func test():
|
||||
print(m_string_array)
|
||||
print(m_stringname_array)
|
||||
|
||||
# Converted to String when initialized
|
||||
var string_array: Array[String] = [&"abc"]
|
||||
print(string_array)
|
||||
|
||||
# Converted to StringName when initialized
|
||||
var stringname_array: Array[StringName] = ["abc"]
|
||||
print(stringname_array)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
["abc"]
|
||||
[&"abc"]
|
||||
["abc"]
|
||||
[&"abc"]
|
16
modules/gdscript/tests/scripts/analyzer/features/as.gd
Normal file
16
modules/gdscript/tests/scripts/analyzer/features/as.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
func test():
|
||||
var some_bool = 5 as bool
|
||||
var some_int = 5 as int
|
||||
var some_float = 5 as float
|
||||
print(typeof(some_bool))
|
||||
print(typeof(some_int))
|
||||
print(typeof(some_float))
|
||||
|
||||
print()
|
||||
|
||||
var some_bool_typed := 5 as bool
|
||||
var some_int_typed := 5 as int
|
||||
var some_float_typed := 5 as float
|
||||
print(typeof(some_bool_typed))
|
||||
print(typeof(some_int_typed))
|
||||
print(typeof(some_float_typed))
|
8
modules/gdscript/tests/scripts/analyzer/features/as.out
Normal file
8
modules/gdscript/tests/scripts/analyzer/features/as.out
Normal file
@@ -0,0 +1,8 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
1
|
||||
2
|
||||
3
|
@@ -0,0 +1,6 @@
|
||||
func test():
|
||||
var never: Variant = false
|
||||
if never:
|
||||
assert(false)
|
||||
assert(false, 'message')
|
||||
print('ok')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,13 @@
|
||||
# https://github.com/godotengine/godot/issues/72501
|
||||
extends Node
|
||||
|
||||
func test():
|
||||
prints("before", process_mode)
|
||||
process_mode = PROCESS_MODE_PAUSABLE
|
||||
prints("after", process_mode)
|
||||
|
||||
var node := Node.new()
|
||||
add_child(node)
|
||||
prints("before", node.process_mode)
|
||||
node.process_mode = PROCESS_MODE_PAUSABLE
|
||||
prints("after", node.process_mode)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
before 0
|
||||
after 1
|
||||
before 0
|
||||
after 1
|
@@ -0,0 +1,14 @@
|
||||
func test():
|
||||
var two: Variant = 0
|
||||
two += 2
|
||||
print(two)
|
||||
|
||||
var three_0: Variant = 1
|
||||
var three_1: int = 2
|
||||
three_0 += three_1
|
||||
print(three_0)
|
||||
|
||||
var four_0: int = 3
|
||||
var four_1: Variant = 1
|
||||
four_0 += four_1
|
||||
print(four_0)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
2
|
||||
3
|
||||
4
|
@@ -0,0 +1,15 @@
|
||||
const const_color: Color = 'red'
|
||||
|
||||
func func_color(arg_color: Color = 'blue') -> bool:
|
||||
return arg_color == Color.BLUE
|
||||
|
||||
func test():
|
||||
Utils.check(const_color == Color.RED)
|
||||
|
||||
Utils.check(func_color() == true)
|
||||
Utils.check(func_color('blue') == true)
|
||||
|
||||
var var_color: Color = 'green'
|
||||
Utils.check(var_color == Color.GREEN)
|
||||
|
||||
print('ok')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,9 @@
|
||||
func inferred_parameter(param = null):
|
||||
if param == null:
|
||||
param = Node.new()
|
||||
param.name = "Ok"
|
||||
print(param.name)
|
||||
param.free()
|
||||
|
||||
func test():
|
||||
inferred_parameter()
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
~~ WARNING at line 6: (UNSAFE_METHOD_ACCESS) The method "free()" is not present on the inferred type "Variant" (but may be present on a subtype).
|
||||
Ok
|
@@ -0,0 +1,15 @@
|
||||
func coroutine() -> int:
|
||||
@warning_ignore("redundant_await")
|
||||
await 0
|
||||
return 1
|
||||
|
||||
func not_coroutine() -> int:
|
||||
return 2
|
||||
|
||||
func test():
|
||||
var a := await coroutine()
|
||||
@warning_ignore("redundant_await")
|
||||
var b := await not_coroutine()
|
||||
@warning_ignore("redundant_await")
|
||||
var c := await 3
|
||||
prints(a, b, c)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
1 2 3
|
@@ -0,0 +1,12 @@
|
||||
# https://github.com/godotengine/godot/issues/54589
|
||||
# https://github.com/godotengine/godot/issues/56265
|
||||
|
||||
extends Resource
|
||||
|
||||
func test():
|
||||
print("okay")
|
||||
await self.changed
|
||||
await unknown(self)
|
||||
|
||||
func unknown(arg):
|
||||
await arg.changed
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
okay
|
@@ -0,0 +1,13 @@
|
||||
const A: = preload("base_outer_resolution_a.notest.gd")
|
||||
const B: = preload("base_outer_resolution_b.notest.gd")
|
||||
const C: = preload("base_outer_resolution_c.notest.gd")
|
||||
|
||||
const Extend: = preload("base_outer_resolution_extend.notest.gd")
|
||||
|
||||
func test() -> void:
|
||||
Extend.test_a(A.new())
|
||||
Extend.test_b(B.new())
|
||||
Extend.InnerClass.test_c(C.new())
|
||||
Extend.InnerClass.InnerInnerClass.test_a_b_c(A.new(), B.new(), C.new())
|
||||
Extend.InnerClass.InnerInnerClass.test_enum(C.TestEnum.HELLO_WORLD)
|
||||
Extend.InnerClass.InnerInnerClass.test_a_prime(A.APrime.new())
|
@@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
@@ -0,0 +1,2 @@
|
||||
class APrime:
|
||||
pass
|
@@ -0,0 +1,4 @@
|
||||
const A: = preload("base_outer_resolution_a.notest.gd")
|
||||
|
||||
class InnerClassInBase:
|
||||
const C: = preload("base_outer_resolution_c.notest.gd")
|
@@ -0,0 +1,3 @@
|
||||
enum TestEnum {
|
||||
HELLO_WORLD
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
extends "base_outer_resolution_base.notest.gd"
|
||||
|
||||
const B: = preload("base_outer_resolution_b.notest.gd")
|
||||
|
||||
static func test_a(a: A) -> void:
|
||||
print(a is A)
|
||||
|
||||
static func test_b(b: B) -> void:
|
||||
print(b is B)
|
||||
|
||||
class InnerClass extends InnerClassInBase:
|
||||
static func test_c(c: C) -> void:
|
||||
print(c is C)
|
||||
|
||||
class InnerInnerClass:
|
||||
static func test_a_b_c(a: A, b: B, c: C) -> void:
|
||||
print(a is A and b is B and c is C)
|
||||
|
||||
static func test_enum(test_enum: C.TestEnum) -> void:
|
||||
print(test_enum == C.TestEnum.HELLO_WORLD)
|
||||
|
||||
static func test_a_prime(a_prime: A.APrime) -> void:
|
||||
print(a_prime is A.APrime)
|
@@ -0,0 +1,356 @@
|
||||
extends Resource
|
||||
|
||||
signal foo
|
||||
|
||||
func test():
|
||||
var x
|
||||
# TYPE_NIL
|
||||
x = null
|
||||
prints("TYPE_NIL")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_BOOL
|
||||
x = true
|
||||
prints("TYPE_BOOL")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_INT
|
||||
x = 1
|
||||
prints("TYPE_INT")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_FLOAT
|
||||
x = 1.1
|
||||
prints("TYPE_FLOAT")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_STRING
|
||||
x = "foo"
|
||||
prints("TYPE_STRING")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_VECTOR2
|
||||
x = Vector2(1, 1)
|
||||
prints("TYPE_VECTOR2")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_VECTOR2I
|
||||
x = Vector2i(1, 1)
|
||||
prints("TYPE_VECTOR2I")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_RECT2
|
||||
x = Rect2(1, 1, 1, 1)
|
||||
prints("TYPE_RECT2")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_RECT2I
|
||||
x = Rect2i(1, 1, 1, 1)
|
||||
prints("TYPE_RECT2I")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_VECTOR3
|
||||
x = Vector3(1, 1, 1)
|
||||
prints("TYPE_VECTOR3")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_VECTOR3I
|
||||
x = Vector3i(1, 1, 1)
|
||||
prints("TYPE_VECTOR3I")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_TRANSFORM2D
|
||||
x = Transform2D.IDENTITY
|
||||
prints("TYPE_TRANSFORM2D")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_VECTOR4
|
||||
x = Vector4(1, 1, 1, 1)
|
||||
prints("TYPE_VECTOR4")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_VECTOR4I
|
||||
x = Vector4i(1, 1, 1, 1)
|
||||
prints("TYPE_VECTOR4I")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PLANE
|
||||
x = Plane.PLANE_XY
|
||||
prints("TYPE_PLANE")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_QUATERNION
|
||||
x = Quaternion.IDENTITY
|
||||
prints("TYPE_QUATERNION")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_AABB
|
||||
x = AABB(Vector3.ONE, Vector3.ONE)
|
||||
prints("TYPE_AABB")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_BASIS
|
||||
x = Basis.IDENTITY
|
||||
prints("TYPE_BASIS")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_TRANSFORM3D
|
||||
x = Transform3D.IDENTITY
|
||||
prints("TYPE_TRANSFORM3D")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PROJECTION
|
||||
x = Projection.IDENTITY
|
||||
prints("TYPE_PROJECTION")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_COLOR
|
||||
x = Color.WHITE
|
||||
prints("TYPE_COLOR")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_STRING_NAME
|
||||
x = &"name"
|
||||
prints("TYPE_STRING_NAME")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_NODE_PATH
|
||||
x = ^"path"
|
||||
prints("TYPE_NODE_PATH")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_RID
|
||||
x = get_rid()
|
||||
prints("TYPE_RID")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_OBJECT
|
||||
x = self
|
||||
prints("TYPE_OBJECT")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_CALLABLE
|
||||
x = test
|
||||
prints("TYPE_CALLABLE")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_SIGNAL
|
||||
x = foo
|
||||
prints("TYPE_SIGNAL")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_DICTIONARY
|
||||
x = { a = 1}
|
||||
prints("TYPE_DICTIONARY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_ARRAY
|
||||
x = [1]
|
||||
prints("TYPE_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_BYTE_ARRAY
|
||||
x = PackedByteArray([1])
|
||||
prints("TYPE_PACKED_BYTE_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_INT32_ARRAY
|
||||
x = PackedInt32Array([1])
|
||||
prints("TYPE_PACKED_INT32_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_INT64_ARRAY
|
||||
x = PackedInt64Array([1])
|
||||
prints("TYPE_PACKED_INT64_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_FLOAT32_ARRAY
|
||||
x = PackedFloat32Array([1])
|
||||
prints("TYPE_PACKED_FLOAT32_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_FLOAT64_ARRAY
|
||||
x = PackedFloat64Array([1])
|
||||
prints("TYPE_PACKED_FLOAT64_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_STRING_ARRAY
|
||||
x = PackedStringArray(["1"])
|
||||
prints("TYPE_PACKED_STRING_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_VECTOR2_ARRAY
|
||||
x = PackedVector2Array([Vector2.ONE])
|
||||
prints("TYPE_PACKED_VECTOR2_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_VECTOR3_ARRAY
|
||||
x = PackedVector3Array([Vector3.ONE])
|
||||
prints("TYPE_PACKED_VECTOR3_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_COLOR_ARRAY
|
||||
x = PackedColorArray([Color.WHITE])
|
||||
prints("TYPE_PACKED_COLOR_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
||||
|
||||
# TYPE_PACKED_VECTOR4_ARRAY
|
||||
x = PackedVector4Array([Vector4.ONE])
|
||||
prints("TYPE_PACKED_VECTOR4_ARRAY")
|
||||
prints(not x)
|
||||
prints(x and false)
|
||||
prints(x and true)
|
||||
prints(x or false)
|
||||
prints(x or true)
|
@@ -0,0 +1,235 @@
|
||||
GDTEST_OK
|
||||
TYPE_NIL
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_BOOL
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_INT
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_FLOAT
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_STRING
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_VECTOR2
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_VECTOR2I
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_RECT2
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_RECT2I
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_VECTOR3
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_VECTOR3I
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_TRANSFORM2D
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_VECTOR4
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_VECTOR4I
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PLANE
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_QUATERNION
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_AABB
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_BASIS
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_TRANSFORM3D
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_PROJECTION
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_COLOR
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_STRING_NAME
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_NODE_PATH
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_RID
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
TYPE_OBJECT
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_CALLABLE
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_SIGNAL
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_DICTIONARY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_BYTE_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_INT32_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_INT64_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_FLOAT32_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_FLOAT64_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_STRING_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_VECTOR2_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_VECTOR3_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_COLOR_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
TYPE_PACKED_VECTOR4_ARRAY
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
@@ -0,0 +1,9 @@
|
||||
extends Node
|
||||
|
||||
func test():
|
||||
set_name("TestNodeName")
|
||||
if get_name() == &"TestNodeName":
|
||||
print("Name is equal")
|
||||
else:
|
||||
print("Name is not equal")
|
||||
print(get_name() is StringName)
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
Name is equal
|
||||
true
|
@@ -0,0 +1,3 @@
|
||||
func test():
|
||||
print(Color.html_is_valid("00ffff"))
|
||||
print("OK")
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
OK
|
@@ -0,0 +1,8 @@
|
||||
# GH-85882
|
||||
|
||||
enum Foo { A, B, C }
|
||||
|
||||
func test():
|
||||
var a := Foo.A
|
||||
var b := a as int + 1
|
||||
print(b)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
1
|
@@ -0,0 +1,5 @@
|
||||
# https://github.com/godotengine/godot/issues/69504#issuecomment-1345725988
|
||||
|
||||
func test():
|
||||
print("cast to Variant == null: ", 1 as Variant == null)
|
||||
print("cast to Object == null: ", self as Object == null)
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
cast to Variant == null: false
|
||||
cast to Object == null: false
|
@@ -0,0 +1,19 @@
|
||||
class A:
|
||||
var x = 3
|
||||
|
||||
class B:
|
||||
var x = 4
|
||||
|
||||
class C:
|
||||
var x = 5
|
||||
|
||||
class Test:
|
||||
var a = A.new()
|
||||
var b: B = B.new()
|
||||
var c := C.new()
|
||||
|
||||
func test():
|
||||
var test_instance := Test.new()
|
||||
prints(test_instance.a.x)
|
||||
prints(test_instance.b.x)
|
||||
prints(test_instance.c.x)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
3
|
||||
4
|
||||
5
|
@@ -0,0 +1,11 @@
|
||||
# https://github.com/godotengine/godot/issues/43503
|
||||
|
||||
var test_var = null
|
||||
|
||||
|
||||
func test():
|
||||
print(test_var.x)
|
||||
|
||||
|
||||
func _init():
|
||||
test_var = Vector3()
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
0.0
|
@@ -0,0 +1,64 @@
|
||||
const A1 = Array()
|
||||
const A2 = Array(Array())
|
||||
const A3 = Array([])
|
||||
const A4 = [Array()]
|
||||
const A5 = [[]]
|
||||
const A6 = Array([1], TYPE_INT, &"", null)
|
||||
|
||||
const D1 = Dictionary()
|
||||
const D2 = Dictionary(Dictionary())
|
||||
const D3 = Dictionary({})
|
||||
const D4 = { Dictionary(): Dictionary() }
|
||||
const D5 = { {}: {} }
|
||||
const D6 = Dictionary({ 1: 1 }, TYPE_INT, &"", null, TYPE_INT, &"", null)
|
||||
|
||||
var a1 = Array()
|
||||
var a2 = Array(Array())
|
||||
var a3 = Array([])
|
||||
var a4 = [Array()]
|
||||
var a5 = [[]]
|
||||
var a6 = Array([1], TYPE_INT, &"", null)
|
||||
|
||||
var d1 = Dictionary()
|
||||
var d2 = Dictionary(Dictionary())
|
||||
var d3 = Dictionary({})
|
||||
var d4 = { Dictionary(): Dictionary() }
|
||||
var d5 = { {}: {} }
|
||||
var d6 = Dictionary({ 1: 1 }, TYPE_INT, &"", null, TYPE_INT, &"", null)
|
||||
|
||||
func test_value(value: Variant) -> void:
|
||||
@warning_ignore("unsafe_method_access")
|
||||
prints(value.is_read_only(), var_to_str(value).replace("\n", " "))
|
||||
|
||||
func test():
|
||||
print('---')
|
||||
test_value(A1)
|
||||
test_value(A2)
|
||||
test_value(A3)
|
||||
test_value(A4)
|
||||
test_value(A5)
|
||||
test_value(A6)
|
||||
|
||||
print('---')
|
||||
test_value(D1)
|
||||
test_value(D2)
|
||||
test_value(D3)
|
||||
test_value(D4)
|
||||
test_value(D5)
|
||||
test_value(D6)
|
||||
|
||||
print('---')
|
||||
test_value(a1)
|
||||
test_value(a2)
|
||||
test_value(a3)
|
||||
test_value(a4)
|
||||
test_value(a5)
|
||||
test_value(a6)
|
||||
|
||||
print('---')
|
||||
test_value(d1)
|
||||
test_value(d2)
|
||||
test_value(d3)
|
||||
test_value(d4)
|
||||
test_value(d5)
|
||||
test_value(d6)
|
@@ -0,0 +1,29 @@
|
||||
GDTEST_OK
|
||||
---
|
||||
true []
|
||||
true []
|
||||
true []
|
||||
true [[]]
|
||||
true [[]]
|
||||
true Array[int]([1])
|
||||
---
|
||||
true {}
|
||||
true {}
|
||||
true {}
|
||||
true { {}: {} }
|
||||
true { {}: {} }
|
||||
true Dictionary[int, int]({ 1: 1 })
|
||||
---
|
||||
false []
|
||||
false []
|
||||
false []
|
||||
false [[]]
|
||||
false [[]]
|
||||
false Array[int]([1])
|
||||
---
|
||||
false {}
|
||||
false {}
|
||||
false {}
|
||||
false { {}: {} }
|
||||
false { {}: {} }
|
||||
false Dictionary[int, int]({ 1: 1 })
|
@@ -0,0 +1,23 @@
|
||||
const const_float_int: float = 19
|
||||
const const_float_plus: float = 12 + 22
|
||||
const const_float_cast: float = 76 as float
|
||||
|
||||
const const_packed_empty: PackedFloat64Array = []
|
||||
const const_packed_ints: PackedFloat64Array = [52]
|
||||
|
||||
func test():
|
||||
Utils.check(typeof(const_float_int) == TYPE_FLOAT)
|
||||
Utils.check(str(const_float_int) == '19.0')
|
||||
Utils.check(typeof(const_float_plus) == TYPE_FLOAT)
|
||||
Utils.check(str(const_float_plus) == '34.0')
|
||||
Utils.check(typeof(const_float_cast) == TYPE_FLOAT)
|
||||
Utils.check(str(const_float_cast) == '76.0')
|
||||
|
||||
Utils.check(typeof(const_packed_empty) == TYPE_PACKED_FLOAT64_ARRAY)
|
||||
Utils.check(str(const_packed_empty) == '[]')
|
||||
Utils.check(typeof(const_packed_ints) == TYPE_PACKED_FLOAT64_ARRAY)
|
||||
Utils.check(str(const_packed_ints) == '[52.0]')
|
||||
Utils.check(typeof(const_packed_ints[0]) == TYPE_FLOAT)
|
||||
Utils.check(str(const_packed_ints[0]) == '52.0')
|
||||
|
||||
print('ok')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,16 @@
|
||||
extends Node
|
||||
|
||||
const NO_TYPE_CONST = 0
|
||||
const TYPE_CONST: int = 1
|
||||
const GUESS_TYPE_CONST := 2
|
||||
|
||||
class Test:
|
||||
var a = NO_TYPE_CONST
|
||||
var b = TYPE_CONST
|
||||
var c = GUESS_TYPE_CONST
|
||||
|
||||
func test():
|
||||
var test_instance = Test.new()
|
||||
prints("a", test_instance.a, test_instance.a == NO_TYPE_CONST)
|
||||
prints("b", test_instance.b, test_instance.b == TYPE_CONST)
|
||||
prints("c", test_instance.c, test_instance.c == GUESS_TYPE_CONST)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 true
|
||||
b 1 true
|
||||
c 2 true
|
@@ -0,0 +1,6 @@
|
||||
func check(arg: float = 3):
|
||||
return typeof(arg) == typeof(3.0)
|
||||
|
||||
func test():
|
||||
if check():
|
||||
print('ok')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,29 @@
|
||||
class_name EnumAccessOuterClass
|
||||
|
||||
class InnerClass:
|
||||
enum MyEnum { V0, V2, V1 }
|
||||
|
||||
static func print_enums():
|
||||
print("Inner - Inner")
|
||||
print(MyEnum.V0, MyEnum.V1, MyEnum.V2)
|
||||
print(InnerClass.MyEnum.V0, InnerClass.MyEnum.V1, InnerClass.MyEnum.V2)
|
||||
print(EnumAccessOuterClass.InnerClass.MyEnum.V0, EnumAccessOuterClass.InnerClass.MyEnum.V1, EnumAccessOuterClass.InnerClass.MyEnum.V2)
|
||||
|
||||
print("Inner - Outer")
|
||||
print(EnumAccessOuterClass.MyEnum.V0, EnumAccessOuterClass.MyEnum.V1, EnumAccessOuterClass.MyEnum.V2)
|
||||
|
||||
|
||||
enum MyEnum { V0, V1, V2 }
|
||||
|
||||
func print_enums():
|
||||
print("Outer - Outer")
|
||||
print(MyEnum.V0, MyEnum.V1, MyEnum.V2)
|
||||
print(EnumAccessOuterClass.MyEnum.V0, EnumAccessOuterClass.MyEnum.V1, EnumAccessOuterClass.MyEnum.V2)
|
||||
|
||||
print("Outer - Inner")
|
||||
print(InnerClass.MyEnum.V0, InnerClass.MyEnum.V1, InnerClass.MyEnum.V2)
|
||||
print(EnumAccessOuterClass.InnerClass.MyEnum.V0, EnumAccessOuterClass.InnerClass.MyEnum.V1, EnumAccessOuterClass.InnerClass.MyEnum.V2)
|
||||
|
||||
func test():
|
||||
print_enums()
|
||||
InnerClass.print_enums()
|
@@ -0,0 +1,13 @@
|
||||
GDTEST_OK
|
||||
Outer - Outer
|
||||
012
|
||||
012
|
||||
Outer - Inner
|
||||
021
|
||||
021
|
||||
Inner - Inner
|
||||
021
|
||||
021
|
||||
021
|
||||
Inner - Outer
|
||||
012
|
@@ -0,0 +1,29 @@
|
||||
class Outer:
|
||||
enum OuterEnum { OuterValue = 3 }
|
||||
const OuterConst := OuterEnum
|
||||
|
||||
class Inner:
|
||||
enum InnerEnum { InnerValue = 7 }
|
||||
const InnerConst := InnerEnum
|
||||
|
||||
static func test() -> void:
|
||||
print(OuterEnum.size());
|
||||
print(OuterEnum.OuterValue);
|
||||
print(OuterConst.size());
|
||||
print(OuterConst.OuterValue);
|
||||
print(Outer.OuterEnum.size());
|
||||
print(Outer.OuterEnum.OuterValue);
|
||||
print(Outer.OuterConst.size());
|
||||
print(Outer.OuterConst.OuterValue);
|
||||
|
||||
print(InnerEnum.size());
|
||||
print(InnerEnum.InnerValue);
|
||||
print(InnerConst.size());
|
||||
print(InnerConst.InnerValue);
|
||||
print(Inner.InnerEnum.size());
|
||||
print(Inner.InnerEnum.InnerValue);
|
||||
print(Inner.InnerConst.size());
|
||||
print(Inner.InnerConst.InnerValue);
|
||||
|
||||
func test():
|
||||
Outer.Inner.test()
|
@@ -0,0 +1,17 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
3
|
||||
1
|
||||
3
|
||||
1
|
||||
3
|
||||
1
|
||||
3
|
||||
1
|
||||
7
|
||||
1
|
||||
7
|
||||
1
|
||||
7
|
||||
1
|
||||
7
|
@@ -0,0 +1,13 @@
|
||||
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
|
||||
|
||||
var class_var: int = MyEnum.ENUM_VALUE_1
|
||||
|
||||
func test():
|
||||
print(class_var)
|
||||
class_var = MyEnum.ENUM_VALUE_2
|
||||
print(class_var)
|
||||
|
||||
var local_var: int = MyEnum.ENUM_VALUE_1
|
||||
print(local_var)
|
||||
local_var = MyEnum.ENUM_VALUE_2
|
||||
print(local_var)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
@@ -0,0 +1,13 @@
|
||||
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
|
||||
|
||||
var class_var: MyEnum = 0 as MyEnum
|
||||
|
||||
func test():
|
||||
print(class_var)
|
||||
class_var = 1 as MyEnum
|
||||
print(class_var)
|
||||
|
||||
var local_var: MyEnum = 0 as MyEnum
|
||||
print(local_var)
|
||||
local_var = 1 as MyEnum
|
||||
print(local_var)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
@@ -0,0 +1,14 @@
|
||||
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
|
||||
enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 }
|
||||
|
||||
var class_var: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1 as MyEnum
|
||||
|
||||
func test():
|
||||
print(class_var)
|
||||
class_var = MyOtherEnum.OTHER_ENUM_VALUE_2 as MyEnum
|
||||
print(class_var)
|
||||
|
||||
var local_var: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1 as MyEnum
|
||||
print(local_var)
|
||||
local_var = MyOtherEnum.OTHER_ENUM_VALUE_2 as MyEnum
|
||||
print(local_var)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
@@ -0,0 +1,13 @@
|
||||
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
|
||||
|
||||
var class_var: MyEnum = MyEnum.ENUM_VALUE_1
|
||||
|
||||
func test():
|
||||
print(class_var)
|
||||
class_var = MyEnum.ENUM_VALUE_2
|
||||
print(class_var)
|
||||
|
||||
var local_var: MyEnum = MyEnum.ENUM_VALUE_1
|
||||
print(local_var)
|
||||
local_var = MyEnum.ENUM_VALUE_2
|
||||
print(local_var)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
@@ -0,0 +1,13 @@
|
||||
enum Enum {V1, V2}
|
||||
|
||||
func test():
|
||||
var enumAsDict: Dictionary = Enum.duplicate()
|
||||
var enumAsVariant = Enum.duplicate()
|
||||
print(Enum.has("V1"))
|
||||
print(enumAsDict.has("V1"))
|
||||
print(enumAsVariant.has("V1"))
|
||||
enumAsDict.clear()
|
||||
enumAsVariant.clear()
|
||||
print(Enum.has("V1"))
|
||||
print(enumAsDict.has("V1"))
|
||||
print(enumAsVariant.has("V1"))
|
@@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
@@ -0,0 +1,13 @@
|
||||
class A:
|
||||
enum Named { VALUE_A, VALUE_B, VALUE_C = 42 }
|
||||
|
||||
class B extends A:
|
||||
var a = Named.VALUE_A
|
||||
var b = Named.VALUE_B
|
||||
var c = Named.VALUE_C
|
||||
|
||||
func test():
|
||||
var test_instance = B.new()
|
||||
prints("a", test_instance.a, test_instance.a == A.Named.VALUE_A)
|
||||
prints("b", test_instance.b, test_instance.b == A.Named.VALUE_B)
|
||||
prints("c", test_instance.c, test_instance.c == B.Named.VALUE_C)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 true
|
||||
b 1 true
|
||||
c 42 true
|
@@ -0,0 +1,12 @@
|
||||
enum Named { VALUE_A, VALUE_B, VALUE_C = 42 }
|
||||
|
||||
class Test:
|
||||
var a = Named.VALUE_A
|
||||
var b = Named.VALUE_B
|
||||
var c = Named.VALUE_C
|
||||
|
||||
func test():
|
||||
var test_instance = Test.new()
|
||||
prints("a", test_instance.a, test_instance.a == Named.VALUE_A)
|
||||
prints("b", test_instance.b, test_instance.b == Named.VALUE_B)
|
||||
prints("c", test_instance.c, test_instance.c == Named.VALUE_C)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 true
|
||||
b 1 true
|
||||
c 42 true
|
@@ -0,0 +1,112 @@
|
||||
class_name EnumFunctionTypecheckOuterClass
|
||||
|
||||
enum MyEnum { V0, V1, V2 }
|
||||
|
||||
class InnerClass:
|
||||
enum MyEnum { V0, V2, V1 }
|
||||
|
||||
func inner_inner_no_class(e: MyEnum) -> MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func inner_inner_class(e: InnerClass.MyEnum) -> InnerClass.MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func inner_inner_class_class(e: EnumFunctionTypecheckOuterClass.InnerClass.MyEnum) -> EnumFunctionTypecheckOuterClass.InnerClass.MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func inner_outer(e: EnumFunctionTypecheckOuterClass.MyEnum) -> EnumFunctionTypecheckOuterClass.MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func test():
|
||||
var _d
|
||||
print("Inner")
|
||||
|
||||
var o := EnumFunctionTypecheckOuterClass.new()
|
||||
|
||||
_d = o.outer_outer_no_class(EnumFunctionTypecheckOuterClass.MyEnum.V1)
|
||||
print()
|
||||
_d = o.outer_outer_class(EnumFunctionTypecheckOuterClass.MyEnum.V1)
|
||||
print()
|
||||
_d = o.outer_inner_class(MyEnum.V1)
|
||||
_d = o.outer_inner_class(InnerClass.MyEnum.V1)
|
||||
_d = o.outer_inner_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = o.outer_inner_class_class(MyEnum.V1)
|
||||
_d = o.outer_inner_class_class(InnerClass.MyEnum.V1)
|
||||
_d = o.outer_inner_class_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
print()
|
||||
|
||||
|
||||
_d = inner_inner_no_class(MyEnum.V1)
|
||||
_d = inner_inner_no_class(InnerClass.MyEnum.V1)
|
||||
_d = inner_inner_no_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = inner_inner_class(MyEnum.V1)
|
||||
_d = inner_inner_class(InnerClass.MyEnum.V1)
|
||||
_d = inner_inner_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = inner_inner_class_class(MyEnum.V1)
|
||||
_d = inner_inner_class_class(InnerClass.MyEnum.V1)
|
||||
_d = inner_inner_class_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = inner_outer(EnumFunctionTypecheckOuterClass.MyEnum.V1)
|
||||
print()
|
||||
print()
|
||||
|
||||
|
||||
func outer_outer_no_class(e: MyEnum) -> MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func outer_outer_class(e: EnumFunctionTypecheckOuterClass.MyEnum) -> EnumFunctionTypecheckOuterClass.MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func outer_inner_class(e: InnerClass.MyEnum) -> InnerClass.MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func outer_inner_class_class(e: EnumFunctionTypecheckOuterClass.InnerClass.MyEnum) -> EnumFunctionTypecheckOuterClass.InnerClass.MyEnum:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func test():
|
||||
var _d
|
||||
print("Outer")
|
||||
|
||||
_d = outer_outer_no_class(MyEnum.V1)
|
||||
_d = outer_outer_no_class(EnumFunctionTypecheckOuterClass.MyEnum.V1)
|
||||
print()
|
||||
_d = outer_outer_class(MyEnum.V1)
|
||||
_d = outer_outer_class(EnumFunctionTypecheckOuterClass.MyEnum.V1)
|
||||
print()
|
||||
_d = outer_inner_class(InnerClass.MyEnum.V1)
|
||||
_d = outer_inner_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = outer_inner_class_class(InnerClass.MyEnum.V1)
|
||||
_d = outer_inner_class_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
print()
|
||||
|
||||
var i := EnumFunctionTypecheckOuterClass.InnerClass.new()
|
||||
|
||||
_d = i.inner_inner_no_class(InnerClass.MyEnum.V1)
|
||||
_d = i.inner_inner_no_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = i.inner_inner_class(InnerClass.MyEnum.V1)
|
||||
_d = i.inner_inner_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = i.inner_inner_class_class(InnerClass.MyEnum.V1)
|
||||
_d = i.inner_inner_class_class(EnumFunctionTypecheckOuterClass.InnerClass.MyEnum.V1)
|
||||
print()
|
||||
_d = i.inner_outer(MyEnum.V1)
|
||||
_d = i.inner_outer(EnumFunctionTypecheckOuterClass.MyEnum.V1)
|
||||
print()
|
||||
print()
|
||||
|
||||
i.test()
|
@@ -0,0 +1,55 @@
|
||||
GDTEST_OK
|
||||
Outer
|
||||
1
|
||||
1
|
||||
|
||||
1
|
||||
1
|
||||
|
||||
2
|
||||
2
|
||||
|
||||
2
|
||||
2
|
||||
|
||||
|
||||
2
|
||||
2
|
||||
|
||||
2
|
||||
2
|
||||
|
||||
2
|
||||
2
|
||||
|
||||
1
|
||||
1
|
||||
|
||||
|
||||
Inner
|
||||
1
|
||||
|
||||
1
|
||||
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
1
|
@@ -0,0 +1,21 @@
|
||||
# Enum is equivalent to int for comparisons and operations.
|
||||
enum MyEnum {
|
||||
ZERO,
|
||||
ONE,
|
||||
TWO,
|
||||
}
|
||||
|
||||
enum OtherEnum {
|
||||
ZERO,
|
||||
ONE,
|
||||
TWO,
|
||||
}
|
||||
|
||||
func test():
|
||||
print(MyEnum.ZERO == OtherEnum.ZERO)
|
||||
print(MyEnum.ZERO == 1)
|
||||
print(MyEnum.ZERO != OtherEnum.ONE)
|
||||
print(MyEnum.ZERO != 0)
|
||||
|
||||
print(MyEnum.ONE + OtherEnum.TWO)
|
||||
print(2 - MyEnum.ONE)
|
@@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
3
|
||||
1
|
@@ -0,0 +1,16 @@
|
||||
const A := 1
|
||||
enum { B }
|
||||
enum NamedEnum { C }
|
||||
|
||||
class Parent:
|
||||
const D := 2
|
||||
enum { E }
|
||||
enum NamedEnum2 { F }
|
||||
|
||||
class Child extends Parent:
|
||||
enum TestEnum { A, B, C, D, E, F, Node, Object, Child, Parent}
|
||||
|
||||
func test():
|
||||
print(A, B, NamedEnum.C, Parent.D, Parent.E, Parent.NamedEnum2.F)
|
||||
print(Child.TestEnum.A, Child.TestEnum.B, Child.TestEnum.C, Child.TestEnum.D, Child.TestEnum.E, Child.TestEnum.F)
|
||||
print(Child.TestEnum.Node, Child.TestEnum.Object, Child.TestEnum.Child, Child.TestEnum.Parent)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
100200
|
||||
012345
|
||||
6789
|
@@ -0,0 +1,19 @@
|
||||
func print_enum(e: TileSet.TileShape) -> TileSet.TileShape:
|
||||
print(e)
|
||||
return e
|
||||
|
||||
func test():
|
||||
var v: TileSet.TileShape
|
||||
v = TileSet.TILE_SHAPE_SQUARE
|
||||
v = print_enum(v)
|
||||
v = print_enum(TileSet.TILE_SHAPE_SQUARE)
|
||||
v = TileSet.TileShape.TILE_SHAPE_SQUARE
|
||||
v = print_enum(v)
|
||||
v = print_enum(TileSet.TileShape.TILE_SHAPE_SQUARE)
|
||||
|
||||
v = TileSet.TILE_SHAPE_ISOMETRIC
|
||||
v = print_enum(v)
|
||||
v = print_enum(TileSet.TILE_SHAPE_ISOMETRIC)
|
||||
v = TileSet.TileShape.TILE_SHAPE_ISOMETRIC
|
||||
v = print_enum(v)
|
||||
v = print_enum(TileSet.TileShape.TILE_SHAPE_ISOMETRIC)
|
@@ -0,0 +1,9 @@
|
||||
GDTEST_OK
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
@@ -0,0 +1,13 @@
|
||||
enum MyEnum {
|
||||
ZERO,
|
||||
ONE,
|
||||
TWO,
|
||||
}
|
||||
|
||||
func test():
|
||||
for key in MyEnum.keys():
|
||||
prints(key, MyEnum[key])
|
||||
|
||||
# https://github.com/godotengine/godot/issues/55491
|
||||
for key in MyEnum:
|
||||
prints(key, MyEnum[key])
|
@@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
ZERO 0
|
||||
ONE 1
|
||||
TWO 2
|
||||
ZERO 0
|
||||
ONE 1
|
||||
TWO 2
|
@@ -0,0 +1,89 @@
|
||||
class_name EnumTypecheckOuterClass
|
||||
|
||||
enum MyEnum { V0, V1, V2 }
|
||||
|
||||
class InnerClass:
|
||||
enum MyEnum { V0, V2, V1 }
|
||||
|
||||
static func test_inner_from_inner():
|
||||
print("Inner - Inner")
|
||||
var e1: MyEnum
|
||||
var e2: InnerClass.MyEnum
|
||||
var e3: EnumTypecheckOuterClass.InnerClass.MyEnum
|
||||
|
||||
@warning_ignore("unassigned_variable")
|
||||
print("Self ", e1, e2, e3)
|
||||
e1 = MyEnum.V1
|
||||
e2 = MyEnum.V1
|
||||
e3 = MyEnum.V1
|
||||
print("MyEnum ", e1, e2, e3)
|
||||
e1 = InnerClass.MyEnum.V1
|
||||
e2 = InnerClass.MyEnum.V1
|
||||
e3 = InnerClass.MyEnum.V1
|
||||
print("Inner.MyEnum ", e1, e2, e3)
|
||||
e1 = EnumTypecheckOuterClass.InnerClass.MyEnum.V1
|
||||
e2 = EnumTypecheckOuterClass.InnerClass.MyEnum.V1
|
||||
e3 = EnumTypecheckOuterClass.InnerClass.MyEnum.V1
|
||||
print("Outer.Inner.MyEnum ", e1, e2, e3)
|
||||
|
||||
e1 = e2
|
||||
e1 = e3
|
||||
e2 = e1
|
||||
e2 = e3
|
||||
e3 = e1
|
||||
e3 = e2
|
||||
|
||||
print()
|
||||
|
||||
static func test_outer_from_inner():
|
||||
print("Inner - Outer")
|
||||
var e: EnumTypecheckOuterClass.MyEnum
|
||||
|
||||
e = EnumTypecheckOuterClass.MyEnum.V1
|
||||
print("Outer.MyEnum ", e)
|
||||
|
||||
print()
|
||||
|
||||
func test_outer_from_outer():
|
||||
print("Outer - Outer")
|
||||
var e1: MyEnum
|
||||
var e2: EnumTypecheckOuterClass.MyEnum
|
||||
|
||||
@warning_ignore("unassigned_variable")
|
||||
print("Self ", e1, e2)
|
||||
e1 = MyEnum.V1
|
||||
e2 = MyEnum.V1
|
||||
print("Outer ", e1, e2)
|
||||
e1 = EnumTypecheckOuterClass.MyEnum.V1
|
||||
e2 = EnumTypecheckOuterClass.MyEnum.V1
|
||||
print("Outer.MyEnum ", e1, e2)
|
||||
|
||||
e1 = e2
|
||||
e2 = e1
|
||||
|
||||
print()
|
||||
|
||||
func test_inner_from_outer():
|
||||
print("Outer - Inner")
|
||||
var e1: InnerClass.MyEnum
|
||||
var e2: EnumTypecheckOuterClass.InnerClass.MyEnum
|
||||
|
||||
@warning_ignore("unassigned_variable")
|
||||
print("Inner ", e1, e2)
|
||||
e1 = InnerClass.MyEnum.V1
|
||||
e2 = InnerClass.MyEnum.V1
|
||||
print("Outer.Inner ", e1, e2)
|
||||
e1 = EnumTypecheckOuterClass.InnerClass.MyEnum.V1
|
||||
e2 = EnumTypecheckOuterClass.InnerClass.MyEnum.V1
|
||||
print("Outer.Inner.MyEnum ", e1, e2)
|
||||
|
||||
e1 = e2
|
||||
e2 = e1
|
||||
|
||||
print()
|
||||
|
||||
func test():
|
||||
test_outer_from_outer()
|
||||
test_inner_from_outer()
|
||||
InnerClass.test_outer_from_inner()
|
||||
InnerClass.test_inner_from_inner()
|
@@ -0,0 +1,19 @@
|
||||
GDTEST_OK
|
||||
Outer - Outer
|
||||
Self 00
|
||||
Outer 11
|
||||
Outer.MyEnum 11
|
||||
|
||||
Outer - Inner
|
||||
Inner 00
|
||||
Outer.Inner 22
|
||||
Outer.Inner.MyEnum 22
|
||||
|
||||
Inner - Outer
|
||||
Outer.MyEnum 1
|
||||
|
||||
Inner - Inner
|
||||
Self 000
|
||||
MyEnum 222
|
||||
Inner.MyEnum 222
|
||||
Outer.Inner.MyEnum 222
|
@@ -0,0 +1,7 @@
|
||||
enum {
|
||||
V1,
|
||||
V2 = V1,
|
||||
}
|
||||
|
||||
func test():
|
||||
pass
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,14 @@
|
||||
extends Node
|
||||
|
||||
enum { VALUE_A, VALUE_B, VALUE_C = 42 }
|
||||
|
||||
class Test:
|
||||
var a = VALUE_A
|
||||
var b = VALUE_B
|
||||
var c = VALUE_C
|
||||
|
||||
func test():
|
||||
var test_instance = Test.new()
|
||||
prints("a", test_instance.a, test_instance.a == VALUE_A)
|
||||
prints("b", test_instance.b, test_instance.b == VALUE_B)
|
||||
prints("c", test_instance.c, test_instance.c == VALUE_C)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 true
|
||||
b 1 true
|
||||
c 42 true
|
@@ -0,0 +1,9 @@
|
||||
enum E { E0 = 0, E3 = 3 }
|
||||
|
||||
func test():
|
||||
var total := 0
|
||||
for value in range(E.E0, E.E3):
|
||||
var inferable := value
|
||||
total += inferable
|
||||
Utils.check(total == 0 + 1 + 2)
|
||||
print('ok')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,14 @@
|
||||
class_name TestExportEnumAsDictionary
|
||||
|
||||
enum MyEnum {A, B, C}
|
||||
|
||||
@export var test_1 = MyEnum
|
||||
@export var test_2 = MyEnum.A
|
||||
@export var test_3 := MyEnum
|
||||
@export var test_4 := MyEnum.A
|
||||
@export var test_5: MyEnum
|
||||
|
||||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property)
|
@@ -0,0 +1,11 @@
|
||||
GDTEST_OK
|
||||
var test_1: Dictionary
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_2: TestExportEnumAsDictionary.MyEnum
|
||||
hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"TestExportEnumAsDictionary.MyEnum"
|
||||
var test_3: Dictionary
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_4: TestExportEnumAsDictionary.MyEnum
|
||||
hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"TestExportEnumAsDictionary.MyEnum"
|
||||
var test_5: TestExportEnumAsDictionary.MyEnum
|
||||
hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"TestExportEnumAsDictionary.MyEnum"
|
@@ -0,0 +1,19 @@
|
||||
class A extends CanvasItem:
|
||||
func _init():
|
||||
pass
|
||||
|
||||
class B extends A:
|
||||
pass
|
||||
|
||||
class C extends CanvasItem:
|
||||
pass
|
||||
|
||||
@abstract class X:
|
||||
pass
|
||||
|
||||
class Y extends X:
|
||||
func test() -> String:
|
||||
return "ok"
|
||||
|
||||
func test():
|
||||
print(Y.new().test())
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,6 @@
|
||||
const External = preload("external_enum_as_constant_external.notest.gd")
|
||||
const MyEnum = External.MyEnum
|
||||
|
||||
func test():
|
||||
print(MyEnum.WAITING == 0)
|
||||
print(MyEnum.GODOT == 1)
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
@@ -0,0 +1,4 @@
|
||||
enum MyEnum {
|
||||
WAITING,
|
||||
GODOT
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
extends "inner_base.gd".InnerA.InnerAB
|
||||
|
||||
func test():
|
||||
super.test()
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
InnerA.InnerAB.test
|
||||
InnerB.test
|
@@ -0,0 +1,7 @@
|
||||
const External = preload("external_inner_class_as_constant_external.notest.gd")
|
||||
const ExternalInnerClass = External.InnerClass
|
||||
|
||||
func test():
|
||||
var inst_external: ExternalInnerClass = ExternalInnerClass.new()
|
||||
inst_external.x = 4.0
|
||||
print(inst_external.x)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
4.0
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user