1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

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:
Hugo Locurcio
2021-04-19 20:50:52 +02:00
parent a9b600bac0
commit c0083c0f90
190 changed files with 1788 additions and 17 deletions

View File

@@ -0,0 +1,16 @@
func test():
# Indexing from the beginning:
print([1, 2, 3][0])
print([1, 2, 3][1])
print([1, 2, 3][2])
# Indexing from the end:
print([1, 2, 3][-1])
print([1, 2, 3][-2])
print([1, 2, 3][-3])
# Float indices are currently allowed, but should probably be an error?
print([1, 2, 3][0.4])
print([1, 2, 3][0.8])
print([1, 2, 3][1.0])
print([1, 2, 3][-1.0])

View File

@@ -0,0 +1,11 @@
GDTEST_OK
1
2
3
3
2
1
1
1
2
3

View File

@@ -0,0 +1,50 @@
enum Flags {
FIRE = 1 << 1,
ICE = 1 << 2,
SLIPPERY = 1 << 3,
STICKY = 1 << 4,
NONSOLID = 1 << 5,
ALL = FIRE | ICE | SLIPPERY | STICKY | NONSOLID,
}
func test():
var flags = Flags.FIRE | Flags.SLIPPERY
print(flags)
flags = Flags.FIRE & Flags.SLIPPERY
print(flags)
flags = Flags.FIRE ^ Flags.SLIPPERY
print(flags)
flags = Flags.ALL & (Flags.FIRE | Flags.ICE)
print(flags)
flags = (Flags.ALL & Flags.FIRE) | Flags.ICE
print(flags)
flags = Flags.ALL & Flags.FIRE | Flags.ICE
print(flags)
# Enum value must be casted to an integer. Otherwise, a parser error is emitted.
flags &= int(Flags.ICE)
print(flags)
flags ^= int(Flags.ICE)
print(flags)
flags |= int(Flags.STICKY | Flags.SLIPPERY)
print(flags)
print()
var num = 2 << 4
print(num)
num <<= 2
print(num)
num >>= 2
print(num)

View File

@@ -0,0 +1,14 @@
GDTEST_OK
10
0
10
6
6
6
4
0
24
32
128
32

View File

@@ -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)

View File

@@ -0,0 +1,3 @@
GDTEST_OK
constructor with argument 10
constructor with argument 500

View File

@@ -0,0 +1,33 @@
# Test deeply nested class architectures.
class Test:
var depth = 1
class Nested:
var depth_nested = 10
class Test2 extends Test:
var depth2 = 2
class Test3 extends Test2:
var depth3 = 3
class Test4 extends Test3:
var depth4 = 4
class Nested2:
var depth4_nested = 100
func test():
print(Test.new().depth)
print(Test2.new().depth)
print(Test2.new().depth2)
print(Test3.new().depth)
print(Test3.new().depth3)
print(Test4.new().depth)
print(Test4.new().depth4)
print(Test.Nested.new().depth_nested)
print(Test4.Nested2.new().depth4_nested)

View File

@@ -0,0 +1,10 @@
GDTEST_OK
1
1
2
1
3
1
4
10
100

View File

@@ -0,0 +1,5 @@
class_name HelloWorld
@icon("res://path/to/optional/icon.svg")
func test():
pass

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,4 @@
func test():
print(20 + 20)
print("hello" + "world")
print([1, 2] + [3, 4])

View File

@@ -0,0 +1,4 @@
GDTEST_OK
40
helloworld
[1, 2, 3, 4]

View File

@@ -0,0 +1,11 @@
func test():
const _TEST = 12 + 34 - 56 * 78
const _STRING = "yes"
const _VECTOR = Vector2(5, 6)
const _ARRAY = []
const _DICTIONARY = {"this": "dictionary"}
# Create user constants from built-in constants.
const _HELLO = PI + TAU
const _INFINITY = INF
const _NOT_A_NUMBER = NAN

View File

@@ -0,0 +1,33 @@
GDTEST_OK
>> WARNING
>> Line: 2
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_TEST' is declared but never used in the block. If this is intended, prefix it with an underscore: '__TEST'
>> WARNING
>> Line: 3
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_STRING' is declared but never used in the block. If this is intended, prefix it with an underscore: '__STRING'
>> WARNING
>> Line: 4
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_VECTOR' is declared but never used in the block. If this is intended, prefix it with an underscore: '__VECTOR'
>> WARNING
>> Line: 5
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_ARRAY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__ARRAY'
>> WARNING
>> Line: 6
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_DICTIONARY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__DICTIONARY'
>> WARNING
>> Line: 9
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_HELLO' is declared but never used in the block. If this is intended, prefix it with an underscore: '__HELLO'
>> WARNING
>> Line: 10
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_INFINITY' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INFINITY'
>> WARNING
>> Line: 11
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_NOT_A_NUMBER' is declared but never used in the block. If this is intended, prefix it with an underscore: '__NOT_A_NUMBER'

View File

@@ -0,0 +1,37 @@
func test():
# Non-string keys are valid.
print({ 12: "world" }[12])
var contents = {
0: "zero",
0.0: "zero point zero",
null: "null",
false: "false",
[]: "empty array",
Vector2i(): "zero Vector2i",
15: {
22: {
4: ["nesting", "arrays"],
},
},
}
print(contents[0.0])
# Making sure declaration order doesn't affect things...
print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0])
print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0.0])
print(contents[null])
print(contents[false])
print(contents[[]])
print(contents[Vector2i()])
print(contents[15])
print(contents[15][22])
print(contents[15][22][4])
print(contents[15][22][4][0])
print(contents[15][22][4][1])
# Currently fails with "invalid get index 'hello' on base Dictionary".
# Both syntaxes are valid however.
#print({ "hello": "world" }["hello"])
#print({ "hello": "world" }.hello)

View File

@@ -0,0 +1,14 @@
GDTEST_OK
world
zero point zero
zero
zero point zero
null
false
empty array
zero Vector2i
{22:{4:[nesting, arrays]}}
{4:[nesting, arrays]}
[nesting, arrays]
nesting
arrays

View File

@@ -0,0 +1,12 @@
func test():
# Mixing Python-style and Lua-style syntax in the same dictionary declaration
# is allowed.
var dict = {
"hello": {
world = {
"is": "beautiful",
},
},
}
print(dict)

View File

@@ -0,0 +1,2 @@
GDTEST_OK
{hello:{world:{is:beautiful}}}

View File

@@ -0,0 +1,20 @@
extends Node
func test():
# Create the required node structure.
var hello = Node.new()
hello.name = "Hello"
add_child(hello)
var world = Node.new()
world.name = "World"
hello.add_child(world)
# All the ways of writing node paths below with the `$` operator are valid.
# Results are assigned to variables to avoid warnings.
var __ = $Hello
__ = $"Hello"
__ = $Hello/World
__ = $"Hello/World"
__ = $"Hello/.."
__ = $"Hello/../Hello/World"

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,14 @@
enum Size {
S = -10,
M,
L = 0,
XL = 10,
XXL,
}
func test():
print(Size.S)
print(Size.M)
print(Size.L)
print(Size.XL)
print(Size.XXL)

View File

@@ -0,0 +1,6 @@
GDTEST_OK
-10
-9
0
10
11

View File

@@ -0,0 +1,11 @@
@export var example = 99
@export_range(0, 100) var example_range = 100
@export_range(0, 100, 1) var example_range_step = 101
@export_range(0, 100, 1, "or_greater") var example_range_step_or_greater = 102
func test():
print(example)
print(example_range)
print(example_range_step)
print(example_range_step_or_greater)

View File

@@ -0,0 +1,5 @@
GDTEST_OK
99
100
101
102

View File

@@ -0,0 +1,24 @@
func test():
# The following floating-point notations are all valid:
print(is_equal_approx(123., 123))
print(is_equal_approx(.123, 0.123))
print(is_equal_approx(.123e4, 1230))
print(is_equal_approx(123.e4, 1.23e6))
print(is_equal_approx(.123e-1, 0.0123))
print(is_equal_approx(123.e-1, 12.3))
# Same as above, but with negative numbers.
print(is_equal_approx(-123., -123))
print(is_equal_approx(-.123, -0.123))
print(is_equal_approx(-.123e4, -1230))
print(is_equal_approx(-123.e4, -1.23e6))
print(is_equal_approx(-.123e-1, -0.0123))
print(is_equal_approx(-123.e-1, -12.3))
# Same as above, but with explicit positive numbers (which is redundant).
print(is_equal_approx(+123., +123))
print(is_equal_approx(+.123, +0.123))
print(is_equal_approx(+.123e4, +1230))
print(is_equal_approx(+123.e4, +1.23e6))
print(is_equal_approx(+.123e-1, +0.0123))
print(is_equal_approx(+123.e-1, +12.3))

View File

@@ -0,0 +1,19 @@
GDTEST_OK
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true

View File

@@ -0,0 +1,39 @@
func test():
for i in range(5):
print(i)
print()
# Equivalent to the above `for` loop:
for i in 5:
print(i)
print()
for i in range(1, 5):
print(i)
print()
for i in range(1, -5, -1):
print(i)
print()
for i in [2, 4, 6, -8]:
print(i)
print()
for i in [true, false]:
print(i)
print()
for i in [Vector2i(10, 20), Vector2i(-30, -40)]:
print(i)
print()
for i in "Hello_Unicôde_world!_🦄":
print(i)

View File

@@ -0,0 +1,58 @@
GDTEST_OK
0
1
2
3
4
0
1
2
3
4
1
2
3
4
1
0
-1
-2
-3
-4
2
4
6
-8
true
false
(10, 20)
(-30, -40)
H
e
l
l
o
_
U
n
i
c
ô
d
e
_
w
o
r
l
d
!
_
🦄

View File

@@ -0,0 +1,14 @@
func test():
print("dot" in "Godot")
print(not "i" in "team")
print(true in [true, false])
print(not null in [true, false])
print(null in [null])
print(26 in [8, 26, 64, 100])
print(not Vector2i(10, 20) in [Vector2i(20, 10)])
print("apple" in { "apple": "fruit" })
print("apple" in { "apple": null })
print(not "apple" in { "fruit": "apple" })

View File

@@ -0,0 +1,11 @@
GDTEST_OK
true
true
true
true
true
true
true
true
true
true

View File

@@ -0,0 +1,18 @@
func test():
var i = "Hello"
match i:
"Hello":
print("hello")
# This will fall through to the default case below.
continue
"Good bye":
print("bye")
_:
print("default")
var j = 25
match j:
26:
print("This won't match")
_:
print("This will match")

View File

@@ -0,0 +1,4 @@
GDTEST_OK
hello
default
This will match

View File

@@ -0,0 +1,7 @@
func test():
var __ = [
"this",
"is", "a","multiline",
"array", "with mixed indentation and trailing comma",
]

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,10 @@
func test():
var __ = {
"multiline": "dictionary","should": "work",
"even with": "a trailing comma",
}
__ = {
this_also_applies = "to the",
lua_style_syntax = null, foo = null,
}

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,14 @@
func test():
# Line breaks are allowed within parentheses.
if (
1 == 1
and 2 == 2 and
3 == 3
):
pass
# Alternatively, backslashes can be used.
if 1 == 1 \
and 2 == 2 and \
3 == 3:
pass

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,15 @@
func test():
var __ = """
This is a standalone string, not a multiline comment.
Writing both "double" quotes and 'simple' quotes is fine as
long as there is only ""one"" or ''two'' of those in a row, not more.
If you have more quotes, they need to be escaped like this: \"\"\"
"""
__ = '''
Another standalone string, this time with single quotes.
Writing both "double" quotes and 'simple' quotes is fine as
long as there is only ""one"" or ''two'' of those in a row, not more.
If you have more quotes, they need to be escaped like this: \'\'\'
'''

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,17 @@
func test():
Vector2(
1,
2
)
Vector3(
3,
3.5,
4, # Trailing comma should work.
)
Vector2i(1, 2,) # Trailing comma should work.
Vector3i(6,
9,
12)

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,22 @@
func test():
print(+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++2.718)
print()
print(------------------------------------------------------------------2.718)
print(-------------------------------------------------------------------2.718)
print()
print(~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~999)
print()
print(+-+-+-----+------------+++++++---++--++--+--+---+--++2.718)
print()
print(2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 2 / 0.444)
print(153023902390239 % 550 % 29 % 27 % 23 % 17)
print(2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2 >> 2)
print(8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8 ^ -8 ^ 8 ^ 8 ^ 8 ^ 8 ^ 8)

View File

@@ -0,0 +1,82 @@
GDTEST_OK
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
>> WARNING
>> Line: 19
>> INTEGER_DIVISION
>> Integer division, decimal part will be discarded.
2.718
2.718
-2.718
-1000
-2.718
36900.9009009009
2
8192
-8

View File

@@ -0,0 +1,5 @@
func test():
var array = [[[[[[[[[[15]]]]]]]]]]
print(array[0][0][0][0][0][0][0][0])
print(array[0][0][0][0][0][0][0][0][0])
print(array[0][0][0][0][0][0][0][0][0][0])

View File

@@ -0,0 +1,4 @@
GDTEST_OK
[[15]]
[15]
15

View File

@@ -0,0 +1,6 @@
func test():
var dictionary = {1: {2: {3: {4: {5: {6: {7: {8: {"key": "value"}}}}}}}}}
print(dictionary[1][2][3][4][5][6][7])
print(dictionary[1][2][3][4][5][6][7][8])
print(dictionary[1][2][3][4][5][6][7][8].key)
print(dictionary[1][2][3][4][5][6][7][8]["key"])

View File

@@ -0,0 +1,5 @@
GDTEST_OK
{8:{key:value}}
{key:value}
value
value

View File

@@ -0,0 +1,57 @@
func test():
# 20 levels of nesting (and then some).
if true:
print("1")
if true:
print("2")
if true:
print("3")
if true:
print("4")
if true:
print("5")
if true:
print("6")
if true:
print("7")
if true:
print("8")
if true:
print("9")
if true:
print("10")
if true:
print("11")
if true:
print("12")
if true:
print("13")
if true:
print("14")
if true:
print("15")
if true:
print("16")
if true:
print("17")
if true:
print("18")
if true:
print("19")
if true:
print("20")
if false:
print("End")
if true:
if true:
if true:
if true:
if true:
if true:
if true:
if true:
if true:
if true:
if true:
if true:
print("This won't be printed")

View File

@@ -0,0 +1,21 @@
GDTEST_OK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

View File

@@ -0,0 +1,79 @@
func test():
# 20 levels of nesting (and then some).
var number = 1234
match number:
1234:
print("1")
match number:
1234:
print("2")
match number:
1234:
print("3")
continue
_:
print("Should also be printed")
match number:
1234:
print("4")
match number:
_:
print("5")
match number:
false:
print("Should not be printed")
true:
print("Should not be printed")
"hello":
print("Should not be printed")
1234:
print("6")
match number:
_:
print("7")
match number:
1234:
print("8")
match number:
_:
print("9")
match number:
1234:
print("10")
match number:
_:
print("11")
match number:
1234:
print("12")
match number:
_:
print("13")
match number:
1234:
print("14")
match number:
_:
print("15")
match number:
_:
print("16")
match number:
1234:
print("17")
match number:
_:
print("18")
match number:
1234:
print("19")
match number:
_:
print("20")
match number:
[]:
print("Should not be printed")
_:
print("Should not be printed")
5678:
print("Should not be printed either")

View File

@@ -0,0 +1,22 @@
GDTEST_OK
1
2
3
Should also be printed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

View File

@@ -0,0 +1,65 @@
func test():
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((print("Hello world!"))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
print(((((((((((((((((((((((((((((((((((((((((((((((((((((((((("Hello world 2!"))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
print(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(2)) + ((4))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

View File

@@ -0,0 +1,4 @@
GDTEST_OK
Hello world!
Hello world 2!
6

View File

@@ -0,0 +1,12 @@
func test():
# `_` can be used as a separator for numbers in GDScript.
# It can be placed anywhere in the number, except at the beginning.
# Currently, GDScript in the `master` branch only allows using one separator
# per number.
# Results are assigned to variables to avoid warnings.
var __ = 1_23
__ = 123_ # Trailing number separators are OK.
__ = 12_3
__ = 123_456
__ = 0x1234_5678
__ = 0b1001_0101

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,8 @@
func test():
var i = 0
i += 5
i -= 4
i *= 10
i %= 8
i /= 0.25
print(round(i))

View File

@@ -0,0 +1,2 @@
GDTEST_OK
8

View File

@@ -0,0 +1,37 @@
# 4.0+ replacement for `setget`:
var _backing: int = 0
var property:
get:
return _backing + 1000
set(value):
_backing = value - 1000
func test():
print("Not using self:")
print(property)
print(_backing)
property = 5000
print(property)
print(_backing)
_backing = -50
print(property)
print(_backing)
property = 5000
print(property)
print(_backing)
# In Godot 4.0 and later, using `self` no longer makes a difference for
# getter/setter execution in GDScript.
print("Using self:")
print(self.property)
print(self._backing)
self.property = 5000
print(self.property)
print(self._backing)
self._backing = -50
print(self.property)
print(self._backing)
self.property = 5000
print(self.property)
print(self._backing)

View File

@@ -0,0 +1,19 @@
GDTEST_OK
Not using self:
1000
0
5000
4000
950
-50
5000
4000
Using self:
5000
4000
5000
4000
950
-50
5000
4000

View File

@@ -1,2 +1,5 @@
func test():
print("A"); print("B")
print("A"); print("B")
# Multiple semicolons and whitespace between them is also valid.
print("A"); ;;;;; ; print("B");;

View File

@@ -0,0 +1,4 @@
func test():
# 2-space indentation should work, even though the GDScript style guide recommends tabs.
if true:
pass

View File

@@ -0,0 +1 @@
GDTEST_OK

View File

@@ -0,0 +1,13 @@
func test():
# The following lines are equivalent:
var _integer: int = 1
var _integer2 : int = 1
var _inferred := 1
var _inferred2 : = 1
# Type inference is automatic for constants.
const _INTEGER = 1
const _INTEGER_REDUNDANT_TYPED : int = 1
const _INTEGER_REDUNDANT_TYPED2 : int = 1
const _INTEGER_REDUNDANT_INFERRED := 1
const _INTEGER_REDUNDANT_INFERRED2 : = 1

View File

@@ -0,0 +1,21 @@
GDTEST_OK
>> WARNING
>> Line: 9
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_INTEGER' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER'
>> WARNING
>> Line: 10
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_INTEGER_REDUNDANT_TYPED' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_TYPED'
>> WARNING
>> Line: 11
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_INTEGER_REDUNDANT_TYPED2' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_TYPED2'
>> WARNING
>> Line: 12
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_INTEGER_REDUNDANT_INFERRED' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_INFERRED'
>> WARNING
>> Line: 13
>> UNUSED_LOCAL_CONSTANT
>> The local constant '_INTEGER_REDUNDANT_INFERRED2' is declared but never used in the block. If this is intended, prefix it with an underscore: '__INTEGER_REDUNDANT_INFERRED2'

View File

@@ -0,0 +1,18 @@
func test():
print("hello %s" % "world" == "hello world")
print("hello %s" % true == "hello true")
print("hello %s" % false == "hello false")
print("hello %d" % 25 == "hello 25")
print("hello %d %d" % [25, 42] == "hello 25 42")
# Pad with spaces.
print("hello %3d" % 25 == "hello 25")
# Pad with zeroes.
print("hello %03d" % 25 == "hello 025")
print("hello %.02f" % 0.123456 == "hello 0.12")
# Dynamic padding:
# <https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_format_string.html#dynamic-padding>
print("hello %*.*f" % [7, 3, 0.123456] == "hello 0.123")
print("hello %0*.*f" % [7, 3, 0.123456] == "hello 000.123")

View File

@@ -0,0 +1,11 @@
GDTEST_OK
true
true
true
true
true
true
true
true
true
true

View File

@@ -0,0 +1,60 @@
class Say:
var prefix = "S"
func greet():
prefix = "S Greeted"
print("hello")
func say(name):
print(prefix, " say something ", name)
class SayAnotherThing extends Say:
# This currently crashes the engine.
#var prefix = "SAT"
func greet():
prefix = "SAT Greeted"
print("hi")
func say(name):
print(prefix, " say another thing ", name)
class SayNothing extends Say:
# This currently crashes the engine.
#var prefix = "SN"
func greet():
super()
prefix = "SN Greeted"
print("howdy, see above")
func greet_prefix_before_super():
prefix = "SN Greeted"
super.greet()
print("howdy, see above")
func say(name):
super(name + " super'd")
print(prefix, " say nothing... or not? ", name)
func test():
var say = Say.new()
say.greet()
say.say("foo")
print()
var say_another_thing = SayAnotherThing.new()
say_another_thing.greet()
say_another_thing.say("bar")
print()
var say_nothing = SayNothing.new()
say_nothing.greet()
print(say_nothing.prefix)
say_nothing.greet_prefix_before_super()
print(say_nothing.prefix)
# This currently triggers a compiler bug: "compiler bug, function name not found"
#say_nothing.say("baz")

View File

@@ -0,0 +1,13 @@
GDTEST_OK
hello
S Greeted say something foo
hi
SAT Greeted say another thing bar
hello
howdy, see above
SN Greeted
hello
howdy, see above
S Greeted

View File

@@ -0,0 +1,30 @@
func test():
# The assertions below should all evaluate to `true` for this test to pass.
assert(true)
assert(not false)
assert(500)
assert(not 0)
assert(500.5)
assert(not 0.0)
assert("non-empty string")
assert(["non-empty array"])
assert({"non-empty": "dictionary"})
assert(Vector2(1, 0))
assert(Vector2i(-1, -1))
assert(Vector3(0, 0, 0.0001))
assert(Vector3i(0, 0, 10000))
# Zero position is `true` only if the Rect2's size is non-zero.
assert(Rect2(0, 0, 0, 1))
# Zero size is `true` only if the position is non-zero.
assert(Rect2(1, 1, 0, 0))
# Zero position is `true` only if the Rect2's size is non-zero.
assert(Rect2i(0, 0, 0, 1))
# Zero size is `true` only if the position is non-zero.
assert(Rect2i(1, 1, 0, 0))
# A fully black color is only truthy if its alpha component is not equal to `1`.
assert(Color(0, 0, 0, 0.5))

View File

@@ -0,0 +1,65 @@
GDTEST_OK
>> WARNING
>> Line: 3
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 4
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 5
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 6
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 7
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 8
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 9
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 12
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 13
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 14
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 15
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 18
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 21
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 24
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 27
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.
>> WARNING
>> Line: 30
>> ASSERT_ALWAYS_TRUE
>> Assert statement is redundant because the expression is always true.

View File

@@ -3,6 +3,7 @@ var m2 = 22 # Init.
var m3: String # No init, typed.
var m4: String = "44" # Init, typed.
func test():
var loc5 # No init, local.
var loc6 = 66 # Init, local.

View File

@@ -0,0 +1,5 @@
func test():
var i = 0
while i < 5:
print(i)
i += 1

View File

@@ -0,0 +1,6 @@
GDTEST_OK
0
1
2
3
4