Add dozens of new integration tests to the GDScript test suite
This also ignores `.out` files in the file format static checks.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
func test():
|
||||
# Error here.
|
||||
print(2.2 << 4)
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Invalid operands to operator <<, float and int.
|
||||
@@ -0,0 +1,3 @@
|
||||
func test():
|
||||
# Error here.
|
||||
print(2 << 4.4)
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Invalid operands to operator <<, int and float.
|
||||
@@ -0,0 +1,5 @@
|
||||
const CONSTANT = 25
|
||||
|
||||
|
||||
func test():
|
||||
CONSTANT(123)
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Member "CONSTANT" is not a function.
|
||||
@@ -0,0 +1,7 @@
|
||||
enum Size {
|
||||
# Error here. Enum values must be integers.
|
||||
S = 0.0,
|
||||
}
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Enum values must be integers.
|
||||
@@ -0,0 +1,7 @@
|
||||
enum Size {
|
||||
# Error here. Enum values must be integers.
|
||||
S = "hello",
|
||||
}
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Enum values must be integers.
|
||||
@@ -0,0 +1,6 @@
|
||||
func function():
|
||||
pass
|
||||
|
||||
|
||||
func test():
|
||||
function = 25
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Cannot assign a new value to a constant.
|
||||
@@ -0,0 +1,3 @@
|
||||
func test():
|
||||
# Error here. Array indices must be integers.
|
||||
print([0, 1][true])
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Invalid index type "bool" for a base of type "Array".
|
||||
@@ -0,0 +1,2 @@
|
||||
func test():
|
||||
print(true + true)
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Invalid operands to operator +, bool and bool.
|
||||
@@ -0,0 +1,2 @@
|
||||
func test():
|
||||
print({"hello": "world"} + {"godot": "engine"})
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Invalid operands "Dictionary" and "Dictionary" for "+" operator.
|
||||
@@ -0,0 +1,2 @@
|
||||
func test():
|
||||
print("hello" + ["world"])
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Invalid operands "String" and "Array" for "+" operator.
|
||||
@@ -0,0 +1,5 @@
|
||||
func test():
|
||||
var i = 12
|
||||
# Constants must be made of a constant, deterministic expression.
|
||||
# A constant that depends on a variable's value is not a constant expression.
|
||||
const TEST = 13 + i
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Assigned value for constant "TEST" isn't a constant expression.
|
||||
@@ -0,0 +1,3 @@
|
||||
func test():
|
||||
# Number separators may not be placed at the beginning of a number.
|
||||
var __ = _123
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Identifier "_123" not declared in the current scope.
|
||||
@@ -0,0 +1,6 @@
|
||||
func args(a, b):
|
||||
print(a)
|
||||
print(b)
|
||||
|
||||
func test():
|
||||
args(1,)
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Too few arguments for "args()" call. Expected at least 2 but received 1.
|
||||
@@ -0,0 +1,4 @@
|
||||
var property = 25
|
||||
|
||||
func test():
|
||||
property()
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Member "property" is not a function.
|
||||
@@ -0,0 +1,7 @@
|
||||
# See also `parser-warnings/shadowed-constant.gd`.
|
||||
const TEST = 25
|
||||
|
||||
|
||||
func test():
|
||||
# Error here (trying to set a new value to a constant).
|
||||
TEST = 50
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Cannot assign a new value to a constant.
|
||||
@@ -0,0 +1,5 @@
|
||||
func test():
|
||||
const TEST = 25
|
||||
|
||||
# Error here (can't assign a new value to a constant).
|
||||
TEST = 50
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Cannot assign a new value to a constant.
|
||||
@@ -0,0 +1,11 @@
|
||||
# `class` extends RefCounted by default.
|
||||
class Say:
|
||||
func say():
|
||||
super()
|
||||
print("say something")
|
||||
|
||||
|
||||
func test():
|
||||
# RefCounted doesn't have a `say()` method, so the `super()` call in the method
|
||||
# definition will cause a run-time error.
|
||||
Say.new().say()
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Function "say()" not found in base RefCounted.
|
||||
@@ -0,0 +1,16 @@
|
||||
func test():
|
||||
var some_bool = 5 as bool
|
||||
var some_int = 5 as int
|
||||
var some_float = 5 as float
|
||||
print(typeof(some_bool))
|
||||
print(typeof(some_int))
|
||||
print(typeof(some_float))
|
||||
|
||||
print()
|
||||
|
||||
var some_bool_typed := 5 as bool
|
||||
var some_int_typed := 5 as int
|
||||
var some_float_typed := 5 as float
|
||||
print(typeof(some_bool_typed))
|
||||
print(typeof(some_int_typed))
|
||||
print(typeof(some_float_typed))
|
||||
@@ -0,0 +1,8 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
Reference in New Issue
Block a user