Add more integration tests to the GDScript test suite

This also fixes a typo in the `bitwise_float_right_operand.gd` test.
This commit is contained in:
Hugo Locurcio
2021-09-15 19:09:34 +02:00
parent 520462e98c
commit c6ca09dc6f
30 changed files with 245 additions and 2 deletions
@@ -0,0 +1,3 @@
func test() {
print("Hello world!");
}
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Expected ":" after function declaration.
@@ -0,0 +1,2 @@
func test():
var escape = "invalid escape \h <- here"
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Invalid escape in string.
@@ -0,0 +1,5 @@
func test():
var amount = 50
# C-style ternary operator is invalid in GDScript.
# The valid syntax is `"yes" if amount < 60 else "no"`, like in Python.
var ternary = amount < 60 ? "yes" : "no"
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Unexpected "?" in source. If you want a ternary operator, use "truthy_value if true_condition else falsy_value".
@@ -0,0 +1,13 @@
# The VCS conflict marker has only 6 `=` signs instead of 7 to prevent editors like
# Visual Studio Code from recognizing it as an actual VCS conflict marker.
# Nonetheless, the GDScript parser is still expected to find and report the VCS
# conflict marker error correctly.
<<<<<<< HEAD
Hello world
======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086
func test():
pass
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Unexpected "VCS conflict marker" in class body.
@@ -3,9 +3,16 @@
@export_range(0, 100, 1) var example_range_step = 101
@export_range(0, 100, 1, "or_greater") var example_range_step_or_greater = 102
@export var color: Color
@export_color_no_alpha var color_no_alpha: Color
@export_node_path(Sprite2D, Sprite3D, Control, Node) var nodepath := ^"hello"
func test():
print(example)
print(example_range)
print(example_range_step)
print(example_range_step_or_greater)
print(color)
print(color_no_alpha)
print(nodepath)
@@ -3,3 +3,6 @@ GDTEST_OK
100
101
102
(0, 0, 0, 1)
(0, 0, 0, 1)
hello
@@ -0,0 +1,5 @@
func example(_number: int, _number2: int = 5, number3 := 10):
return number3
func test():
print(example(3))
@@ -0,0 +1,5 @@
func example(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25, arg26, arg27, arg28, arg29, arg30, arg31, arg32, arg33, arg34, arg35, arg36, arg37, arg38, arg39, arg40, arg41, arg42, arg43, arg44, arg45, arg46, arg47, arg48 = false, arg49 = true, arg50 = null):
print(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25, arg26, arg27, arg28, arg29, arg30, arg31, arg32, arg33, arg34, arg35, arg36, arg37, arg38, arg39, arg40, arg41, arg42, arg43, arg44, arg45, arg46, arg47, arg48, arg49, arg50)
func test():
example(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47)
@@ -0,0 +1,2 @@
GDTEST_OK
123456789101112131415161718192212223242526272829303132333435363738394041424344454647falsetruenull
@@ -0,0 +1,4 @@
func test():
var my_lambda = func(x):
print(x)
my_lambda.call("hello")
@@ -0,0 +1,2 @@
GDTEST_OK
hello
@@ -0,0 +1,4 @@
func test():
var x = 42
var my_lambda = func(): print(x)
my_lambda.call() # Prints "42".
@@ -0,0 +1,2 @@
GDTEST_OK
42
@@ -0,0 +1,10 @@
func i_take_lambda(lambda: Callable, param: String):
lambda.call(param)
func test():
var my_lambda := func this_is_lambda(x):
print("Hello")
print("This is %s" % x)
i_take_lambda(my_lambda, "a lambda")
@@ -0,0 +1,3 @@
GDTEST_OK
Hello
This is a lambda
@@ -0,0 +1,5 @@
func foo(x):
return x + 1
func test():
print(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(foo(0)))))))))))))))))))))))))
@@ -0,0 +1,2 @@
GDTEST_OK
24
@@ -0,0 +1,5 @@
func test():
var my_array: Array[int] = [1, 2, 3]
var inferred_array := [1, 2, 3] # This is Array[int].
print(my_array)
print(inferred_array)
@@ -0,0 +1,3 @@
GDTEST_OK
[1, 2, 3]
[1, 2, 3]