summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/scripts/parser/features/class.gd
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-09-15 14:00:41 +0200
committerGitHub <noreply@github.com>2021-09-15 14:00:41 +0200
commit32f8f74d8345049e41d1abb7239fcee40ecb2c53 (patch)
tree55ddc531d295c63b76fb953ed83a4fd9b43434e5 /modules/gdscript/tests/scripts/parser/features/class.gd
parentd169087b67995b58a6a6b1394b41bc46e640bd77 (diff)
parentc0083c0f90238f0eec01604dd9c952c8c5dc3c22 (diff)
Merge pull request #48029 from Calinou/gdscript-add-integration-tests
Add dozens of new integration tests to the GDScript test suite
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/features/class.gd')
-rw-r--r--modules/gdscript/tests/scripts/parser/features/class.gd25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/class.gd b/modules/gdscript/tests/scripts/parser/features/class.gd
new file mode 100644
index 0000000000..6652f85ad9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/class.gd
@@ -0,0 +1,25 @@
+# Test non-nested/slightly nested class architecture.
+class Test:
+ var number = 25
+ var string = "hello"
+
+
+class TestSub extends Test:
+ var other_string = "bye"
+
+
+class TestConstructor:
+ func _init(argument = 10):
+ print(str("constructor with argument ", argument))
+
+
+func test():
+ var test_instance = Test.new()
+ test_instance.number = 42
+
+ var test_sub = TestSub.new()
+ assert(test_sub.number == 25) # From Test.
+ assert(test_sub.other_string == "bye") # From TestSub.
+
+ TestConstructor.new()
+ TestConstructor.new(500)