summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2023-06-20 15:12:39 +0200
committerGitHub <noreply@github.com>2023-06-20 15:12:39 +0200
commit248e5245e41ed80069eca12fcb523092fe848f28 (patch)
tree3bc3a42c57a27de041bb46a7346250baca2b9eed /modules/gdscript/tests/scripts
parent904db6e8cbc3902f8ff93149d54f7d6f5d97bcea (diff)
parent2a12213c3180c65847022e8257ce25c37bb8e6b3 (diff)
downloadredot-engine-248e5245e41ed80069eca12fcb523092fe848f28.tar.gz
Merge pull request #73540 from mashumafi/fix-typed-array-add
Fix: Typed arrays aren't working with +
Diffstat (limited to 'modules/gdscript/tests/scripts')
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.gd28
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.out7
2 files changed, 35 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.gd b/modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.gd
new file mode 100644
index 0000000000..ef3ee8d255
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.gd
@@ -0,0 +1,28 @@
+# https://github.com/godotengine/godot/issues/72948
+
+class Example:
+ extends RefCounted
+
+const const_ints : Array[int] = [1, 2, 3]
+
+func test():
+ var ints: Array[int] = [1, 2, 3]
+ var strings: Array[String] = ["4", "5", "6"]
+
+ var ints_concatenated: Array[int] = ints + ints
+ var strings_concatenated: Array[String] = strings + strings
+ var untyped_concatenated: Array = ints + strings
+ var const_ints_concatenated: Array[int] = const_ints + const_ints
+
+ print(ints_concatenated.get_typed_builtin())
+ print(strings_concatenated.get_typed_builtin())
+ print(untyped_concatenated.get_typed_builtin())
+ print(const_ints_concatenated.get_typed_builtin())
+
+ var objects: Array[Object] = []
+ var objects_concatenated: Array[Object] = objects + objects
+ print(objects_concatenated.get_typed_class_name())
+
+ var examples: Array[Example] = []
+ var examples_concatenated: Array[Example] = examples + examples
+ print(examples_concatenated.get_typed_script() == Example)
diff --git a/modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.out b/modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.out
new file mode 100644
index 0000000000..34f1221a78
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/typed_array_concatenation.out
@@ -0,0 +1,7 @@
+GDTEST_OK
+2
+4
+0
+2
+Object
+true