summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
authorstrank <strank@strank.info>2022-03-04 12:17:23 -0500
committerstrank <strank@strank.info>2022-03-04 12:41:20 -0500
commit7d48afa96deb79027f64f9f86c633668c6fb46db (patch)
treed4fecab6d2ab77a7601423297f4d7e4a7c58b996 /modules/gdscript/tests
parentf356c8ac4bfb16be361d8ff21ecbb406baa6e631 (diff)
Add test cases for accessing parent elements from child class
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/scripts/parser/features/class_inheritance_access.gd40
-rw-r--r--modules/gdscript/tests/scripts/parser/features/class_inheritance_access.out16
2 files changed, 56 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/class_inheritance_access.gd b/modules/gdscript/tests/scripts/parser/features/class_inheritance_access.gd
new file mode 100644
index 0000000000..eb392672eb
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/class_inheritance_access.gd
@@ -0,0 +1,40 @@
+# Test access visibility of parent elements in nested class architectures.
+class Parent:
+ const parent_const := 1
+
+ var parent_variable := 2
+
+ signal parent_signal
+
+ var parent_attribute: int:
+ get:
+ return 3
+
+ func parent_func():
+ return 4
+
+ class Nested:
+ const nested_const := 5
+
+
+class Child extends Parent:
+ func child_test():
+ print(parent_const)
+ print(self.parent_const)
+ print(parent_variable)
+ print(self.parent_variable)
+ print(parent_signal.get_name())
+ print(self.parent_signal.get_name())
+ print(parent_attribute)
+ print(self.parent_attribute)
+ print(parent_func.get_method())
+ print(self.parent_func.get_method())
+ print(parent_func())
+ print(self.parent_func())
+ print(Nested.nested_const)
+ print(self.Nested.nested_const)
+ print(Parent.Nested.nested_const)
+
+
+func test():
+ Child.new().child_test()
diff --git a/modules/gdscript/tests/scripts/parser/features/class_inheritance_access.out b/modules/gdscript/tests/scripts/parser/features/class_inheritance_access.out
new file mode 100644
index 0000000000..09e87bccfa
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/class_inheritance_access.out
@@ -0,0 +1,16 @@
+GDTEST_OK
+1
+1
+2
+2
+parent_signal
+parent_signal
+3
+3
+parent_func
+parent_func
+4
+4
+5
+5
+5