Fix GDScript base and outer classes, signals and functions lookup order
- Add outer class lookup test - Add signal lookup test Co-authored-by: Dmitrii Maganov <vonagam@gmail.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# Inner-outer class lookup
|
||||
class A:
|
||||
const Q: = "right one"
|
||||
|
||||
class X:
|
||||
const Q: = "wrong one"
|
||||
|
||||
class Y extends X:
|
||||
class B extends A:
|
||||
static func check() -> void:
|
||||
print(Q)
|
||||
|
||||
# External class lookup
|
||||
const External: = preload("lookup_class_external.notest.gd")
|
||||
|
||||
class Internal extends External.A:
|
||||
static func check() -> void:
|
||||
print(TARGET)
|
||||
|
||||
class E extends External.E:
|
||||
static func check() -> void:
|
||||
print(TARGET)
|
||||
print(WAITING)
|
||||
|
||||
# Variable lookup
|
||||
class C:
|
||||
var Q := 'right one'
|
||||
|
||||
class D:
|
||||
const Q := 'wrong one'
|
||||
|
||||
class E extends D:
|
||||
class F extends C:
|
||||
func check() -> void:
|
||||
print(Q)
|
||||
|
||||
# Test
|
||||
func test() -> void:
|
||||
# Inner-outer class lookup
|
||||
Y.B.check()
|
||||
print("---")
|
||||
|
||||
# External class lookup
|
||||
Internal.check()
|
||||
Internal.E.check()
|
||||
print("---")
|
||||
|
||||
# Variable lookup
|
||||
var f: = E.F.new()
|
||||
f.check()
|
||||
@@ -0,0 +1,8 @@
|
||||
GDTEST_OK
|
||||
right one
|
||||
---
|
||||
wrong
|
||||
right
|
||||
godot
|
||||
---
|
||||
right one
|
||||
@@ -0,0 +1,15 @@
|
||||
class A:
|
||||
const TARGET: = "wrong"
|
||||
|
||||
class B:
|
||||
const TARGET: = "wrong"
|
||||
const WAITING: = "godot"
|
||||
|
||||
class D extends C:
|
||||
pass
|
||||
|
||||
class C:
|
||||
const TARGET: = "right"
|
||||
|
||||
class E extends A.B.D:
|
||||
pass
|
||||
@@ -0,0 +1,41 @@
|
||||
signal hello
|
||||
|
||||
func get_signal() -> Signal:
|
||||
return hello
|
||||
|
||||
class A:
|
||||
signal hello
|
||||
|
||||
func get_signal() -> Signal:
|
||||
return hello
|
||||
|
||||
class B:
|
||||
signal hello
|
||||
|
||||
func get_signal() -> Signal:
|
||||
return hello
|
||||
|
||||
class C extends A.B:
|
||||
func get_signal() -> Signal:
|
||||
return hello
|
||||
|
||||
func test():
|
||||
var a: = A.new()
|
||||
var b: = A.B.new()
|
||||
var c: = C.new()
|
||||
|
||||
var hello_a_result: = hello == a.get_signal()
|
||||
var hello_b_result: = hello == b.get_signal()
|
||||
var hello_c_result: = hello == c.get_signal()
|
||||
var a_b_result: = a.get_signal() == b.get_signal()
|
||||
var a_c_result: = a.get_signal() == c.get_signal()
|
||||
var b_c_result: = b.get_signal() == c.get_signal()
|
||||
var c_c_result: = c.get_signal() == c.get_signal()
|
||||
|
||||
print("hello == A.hello? %s" % hello_a_result)
|
||||
print("hello == A.B.hello? %s" % hello_b_result)
|
||||
print("hello == C.hello? %s" % hello_c_result)
|
||||
print("A.hello == A.B.hello? %s" % a_b_result)
|
||||
print("A.hello == C.hello? %s" % a_c_result)
|
||||
print("A.B.hello == C.hello? %s" % b_c_result)
|
||||
print("C.hello == C.hello? %s" % c_c_result)
|
||||
@@ -0,0 +1,8 @@
|
||||
GDTEST_OK
|
||||
hello == A.hello? false
|
||||
hello == A.B.hello? false
|
||||
hello == C.hello? false
|
||||
A.hello == A.B.hello? false
|
||||
A.hello == C.hello? false
|
||||
A.B.hello == C.hello? false
|
||||
C.hello == C.hello? true
|
||||
Reference in New Issue
Block a user