summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd8
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd53
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out37
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/shadowning.gd12
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out26
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd2
10 files changed, 147 insertions, 2 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd
new file mode 100644
index 0000000000..54cf4d89ec
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd
@@ -0,0 +1,5 @@
+class Foo extends RefCounted.Bar:
+ pass
+
+func test():
+ print('not ok')
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out
new file mode 100644
index 0000000000..386d6261c6
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Cannot get nested types for extension from non-GDScript type "RefCounted".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd
new file mode 100644
index 0000000000..0f7d584edb
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd
@@ -0,0 +1,8 @@
+class Foo:
+ pass
+
+class Bar extends Foo.Baz:
+ pass
+
+func test():
+ print('not ok')
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out
new file mode 100644
index 0000000000..42873056f2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Could not find nested type "Baz".
diff --git a/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd b/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd
index 4c02fd4b0d..292db30bcd 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd
@@ -11,5 +11,5 @@ func test():
print("done")
-func regular_func():
+func regular_func() -> int:
return 0
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd
new file mode 100644
index 0000000000..f8844d66a7
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd
@@ -0,0 +1,53 @@
+signal my_signal()
+
+# CI cannot test async things.
+func test_signals():
+ await my_signal
+ var t: Signal = my_signal
+ await t
+
+func coroutine() -> void:
+ @warning_ignore("redundant_await")
+ await 0
+
+func not_coroutine_variant():
+ pass
+
+func not_coroutine_void() -> void:
+ pass
+
+func test():
+ const CONST_NULL = null
+ var var_null = null
+ var var_int: int = 1
+ var var_variant: Variant = 1
+ var var_array: Array = [1]
+
+ await CONST_NULL
+ await var_null
+ await var_int
+ await var_variant
+ await var_array[0]
+
+ await coroutine
+ await coroutine()
+ await coroutine.call()
+ await self.coroutine()
+ await call(&"coroutine")
+
+ await not_coroutine_variant
+ await not_coroutine_variant()
+ await self.not_coroutine_variant()
+ await not_coroutine_variant.call()
+ await call(&"not_coroutine_variant")
+
+ await not_coroutine_void
+ await not_coroutine_void()
+ await self.not_coroutine_void()
+ await not_coroutine_void.call()
+ await call(&"not_coroutine_void")
+
+ var callable: Callable = coroutine
+ await callable
+ await callable.call()
+ await callable.get_method()
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out
new file mode 100644
index 0000000000..3d251c2906
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out
@@ -0,0 +1,37 @@
+GDTEST_OK
+>> WARNING
+>> Line: 26
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 28
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 32
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 38
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 44
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 45
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 46
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 51
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
+>> WARNING
+>> Line: 53
+>> REDUNDANT_AWAIT
+>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.gd b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.gd
new file mode 100644
index 0000000000..61945c9c8f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.gd
@@ -0,0 +1,12 @@
+var member: int = 0
+
+@warning_ignore("unused_variable")
+func test():
+ var Array := 'Array'
+ var Node := 'Node'
+ var is_same := 'is_same'
+ var sqrt := 'sqrt'
+ var member := 'member'
+ var reference := 'reference'
+
+ print('warn')
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out
new file mode 100644
index 0000000000..9d0e567534
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out
@@ -0,0 +1,26 @@
+GDTEST_OK
+>> WARNING
+>> Line: 5
+>> SHADOWED_GLOBAL_IDENTIFIER
+>> The variable 'Array' has the same name as a built-in type.
+>> WARNING
+>> Line: 6
+>> SHADOWED_GLOBAL_IDENTIFIER
+>> The variable 'Node' has the same name as a global class.
+>> WARNING
+>> Line: 7
+>> SHADOWED_GLOBAL_IDENTIFIER
+>> The variable 'is_same' has the same name as a built-in function.
+>> WARNING
+>> Line: 8
+>> SHADOWED_GLOBAL_IDENTIFIER
+>> The variable 'sqrt' has the same name as a built-in function.
+>> WARNING
+>> Line: 9
+>> SHADOWED_VARIABLE
+>> The local variable "member" is shadowing an already-declared variable at line 1.
+>> WARNING
+>> Line: 10
+>> SHADOWED_VARIABLE_BASE_CLASS
+>> The local variable "reference" is shadowing an already-declared method at the base class "RefCounted".
+warn
diff --git a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd
index 9da61ab184..1c39073be9 100644
--- a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd
@@ -4,5 +4,5 @@ func test():
print(await not_coroutine())
-func not_coroutine():
+func not_coroutine() -> String:
return "awaited"