initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
func foo(x):
|
||||
match x:
|
||||
1 + 1:
|
||||
print("1+1")
|
||||
[1,2,[1,{1:2,2:var z,..}]]:
|
||||
print("[1,2,[1,{1:2,2:var z,..}]]")
|
||||
print(z)
|
||||
1 if true else 2:
|
||||
print("1 if true else 2")
|
||||
1 < 2:
|
||||
print("1 < 2")
|
||||
1 or 2 and 1:
|
||||
print("1 or 2 and 1")
|
||||
6 | 1:
|
||||
print("1 | 1")
|
||||
1 >> 1:
|
||||
print("1 >> 1")
|
||||
1, 2 or 3, 4:
|
||||
print("1, 2 or 3, 4")
|
||||
_:
|
||||
print("wildcard")
|
||||
|
||||
func test():
|
||||
foo(6 | 1)
|
||||
foo(1 >> 1)
|
||||
foo(2)
|
||||
foo(1)
|
||||
foo(1+1)
|
||||
foo(1 < 2)
|
||||
foo([2, 1])
|
||||
foo(4)
|
||||
foo([1, 2, [1, {1 : 2, 2:3}]])
|
||||
foo([1, 2, [1, {1 : 2, 2:[1,3,5, "123"], 4:2}]])
|
||||
foo([1, 2, [1, {1 : 2}]])
|
@@ -0,0 +1,14 @@
|
||||
GDTEST_OK
|
||||
1 | 1
|
||||
1 >> 1
|
||||
1+1
|
||||
1 if true else 2
|
||||
1+1
|
||||
1 < 2
|
||||
wildcard
|
||||
1, 2 or 3, 4
|
||||
[1,2,[1,{1:2,2:var z,..}]]
|
||||
3
|
||||
[1,2,[1,{1:2,2:var z,..}]]
|
||||
[1, 3, 5, "123"]
|
||||
wildcard
|
@@ -0,0 +1,3 @@
|
||||
func test():
|
||||
var P1 = "ok" # Technically it is visually similar to keyword "PI" but allowed since it's in ASCII range.
|
||||
print(P1)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
This is a comment.
|
||||
"""
|
||||
|
||||
@tool
|
||||
|
||||
"""
|
||||
This is also a comment.
|
||||
"""
|
||||
|
||||
extends RefCounted
|
||||
|
||||
'''
|
||||
This is a comment too.
|
||||
'''
|
||||
|
||||
func test():
|
||||
"""
|
||||
This too is a comment.
|
||||
"""
|
||||
print("ok")
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,20 @@
|
||||
func test():
|
||||
# The following keywords are allowed as identifiers:
|
||||
var match = "match"
|
||||
print(match)
|
||||
|
||||
var PI = "PI"
|
||||
print(PI)
|
||||
|
||||
var INF = "INF"
|
||||
print(INF)
|
||||
|
||||
var NAN = "NAN"
|
||||
print(NAN)
|
||||
|
||||
var TAU = "TAU"
|
||||
print(TAU)
|
||||
|
||||
# New keyword for pattern guards.
|
||||
var when = "when"
|
||||
print(when)
|
@@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
match
|
||||
PI
|
||||
INF
|
||||
NAN
|
||||
TAU
|
||||
when
|
@@ -0,0 +1,47 @@
|
||||
extends Node
|
||||
|
||||
@export_enum("A", "B", "C") var test_1
|
||||
@export_enum("A", "B", "C",) var test_2
|
||||
|
||||
@export_enum(
|
||||
"A",
|
||||
"B",
|
||||
"C"
|
||||
) var test_3
|
||||
|
||||
@export_enum(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
) var test_4
|
||||
|
||||
@export
|
||||
var test_5: int
|
||||
|
||||
@export()
|
||||
var test_6: int
|
||||
|
||||
@export() var test_7: int = 42
|
||||
@warning_ignore("onready_with_export") @onready @export var test_8: int = 42
|
||||
@warning_ignore("onready_with_export") @onready() @export() var test_9: int = 42
|
||||
|
||||
@warning_ignore("onready_with_export")
|
||||
@onready
|
||||
@export
|
||||
var test_10: int = 42
|
||||
|
||||
@warning_ignore("onready_with_export")
|
||||
@onready()
|
||||
@export()
|
||||
var test_11: int = 42
|
||||
|
||||
@warning_ignore("onready_with_export")
|
||||
@onready()
|
||||
@export()
|
||||
|
||||
var test_12: int = 42
|
||||
|
||||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property, self)
|
@@ -0,0 +1,25 @@
|
||||
GDTEST_OK
|
||||
var test_1: int = null
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_2: int = null
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_3: int = null
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_4: int = null
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_5: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_6: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_7: int = 42
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_8: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_9: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_10: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_11: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_12: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
16
modules/gdscript/tests/scripts/parser/features/array.gd
Normal file
16
modules/gdscript/tests/scripts/parser/features/array.gd
Normal 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])
|
11
modules/gdscript/tests/scripts/parser/features/array.out
Normal file
11
modules/gdscript/tests/scripts/parser/features/array.out
Normal file
@@ -0,0 +1,11 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
2
|
||||
3
|
||||
3
|
||||
2
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
3
|
@@ -0,0 +1,58 @@
|
||||
# https://github.com/godotengine/godot/issues/50285
|
||||
|
||||
@warning_ignore_start("unused_local_constant")
|
||||
func test():
|
||||
const CONST_INNER_DICTIONARY = { "key": true }
|
||||
const CONST_NESTED_DICTIONARY_OLD_WORKAROUND = {
|
||||
"key1": "value1",
|
||||
"key2": CONST_INNER_DICTIONARY
|
||||
}
|
||||
# All of these should be valid
|
||||
const CONST_NESTED_DICTIONARY = {
|
||||
"key1": "value1",
|
||||
"key2": { "key": true }
|
||||
}
|
||||
|
||||
|
||||
const CONST_DICTIONARY_WITH_ARRAY = {
|
||||
"key1": [1,2,3,4]
|
||||
}
|
||||
|
||||
const CONST_NESTED_ARRAY = [[],[2],[1,2,3]]
|
||||
const CONST_ARRAY_WITH_DICT = [{"key1": 3}, {"key2": 5}]
|
||||
|
||||
const THREE_DIMENSIONAL_ARRAY = [[[],[],[]],[[],[],[]],[[],[],[]]]
|
||||
const MANY_NESTED_DICT = {
|
||||
"key1": {
|
||||
"key11": {
|
||||
"key111": {},
|
||||
"key112": {},
|
||||
},
|
||||
"key12": {
|
||||
"key121": {},
|
||||
"key122": {},
|
||||
},
|
||||
},
|
||||
"key2": {
|
||||
"key21": {
|
||||
"key211": {},
|
||||
"key212": {},
|
||||
},
|
||||
"key22": {
|
||||
"key221": {},
|
||||
"key222": {},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const CONST_ARRAY_ACCESS = [1,2,3][0]
|
||||
const CONST_DICT_ACCESS = {"key1": 5}["key1"]
|
||||
|
||||
const CONST_ARRAY_NESTED_ACCESS = [[1,2,3],[4,5,6],[8,9,10]][0][1]
|
||||
const CONST_DICT_NESTED_ACCESS = {"key1": {"key2": 1}}["key1"]["key2"]
|
||||
|
||||
print(CONST_ARRAY_ACCESS)
|
||||
print(CONST_DICT_ACCESS)
|
||||
print(CONST_ARRAY_NESTED_ACCESS)
|
||||
print(CONST_DICT_NESTED_ACCESS)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
5
|
||||
2
|
||||
1
|
@@ -0,0 +1,27 @@
|
||||
func foo(x):
|
||||
match x:
|
||||
1:
|
||||
print("1")
|
||||
2:
|
||||
print("2")
|
||||
[1, 2]:
|
||||
print("[1, 2]")
|
||||
3 or 4:
|
||||
print("3 or 4")
|
||||
4:
|
||||
print("4")
|
||||
{1 : 2, 2 : 3}:
|
||||
print("{1 : 2, 2 : 3}")
|
||||
_:
|
||||
print("wildcard")
|
||||
|
||||
func test():
|
||||
foo(0)
|
||||
foo(1)
|
||||
foo(2)
|
||||
foo([1, 2])
|
||||
foo(3)
|
||||
foo(4)
|
||||
foo([4,4])
|
||||
foo({1 : 2, 2 : 3})
|
||||
foo({1 : 2, 4 : 3})
|
@@ -0,0 +1,10 @@
|
||||
GDTEST_OK
|
||||
wildcard
|
||||
1
|
||||
2
|
||||
[1, 2]
|
||||
wildcard
|
||||
4
|
||||
wildcard
|
||||
{1 : 2, 2 : 3}
|
||||
wildcard
|
@@ -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)
|
@@ -0,0 +1,14 @@
|
||||
GDTEST_OK
|
||||
10
|
||||
0
|
||||
10
|
||||
6
|
||||
6
|
||||
6
|
||||
4
|
||||
0
|
||||
24
|
||||
|
||||
32
|
||||
128
|
||||
32
|
25
modules/gdscript/tests/scripts/parser/features/class.gd
Normal file
25
modules/gdscript/tests/scripts/parser/features/class.gd
Normal 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()
|
||||
Utils.check(test_sub.number == 25) # From Test.
|
||||
Utils.check(test_sub.other_string == "bye") # From TestSub.
|
||||
|
||||
var _test_constructor = TestConstructor.new()
|
||||
_test_constructor = TestConstructor.new(500)
|
3
modules/gdscript/tests/scripts/parser/features/class.out
Normal file
3
modules/gdscript/tests/scripts/parser/features/class.out
Normal file
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
constructor with argument 10
|
||||
constructor with argument 500
|
@@ -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)
|
@@ -0,0 +1,10 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
1
|
||||
2
|
||||
1
|
||||
3
|
||||
1
|
||||
4
|
||||
10
|
||||
100
|
@@ -0,0 +1,41 @@
|
||||
# Test access visibility of parent elements in nested class architectures.
|
||||
class Parent:
|
||||
const parent_const := 1
|
||||
|
||||
var parent_variable := 2
|
||||
|
||||
@warning_ignore("unused_signal")
|
||||
signal parent_signal
|
||||
|
||||
var parent_attribute: int:
|
||||
get:
|
||||
return 3
|
||||
|
||||
func parent_func():
|
||||
return 4
|
||||
|
||||
class Nested:
|
||||
const nested_const := 5
|
||||
|
||||
|
||||
class Child extends Parent:
|
||||
func child_test():
|
||||
print(parent_const)
|
||||
print(self.parent_const)
|
||||
print(parent_variable)
|
||||
print(self.parent_variable)
|
||||
print(parent_signal.get_name())
|
||||
print(self.parent_signal.get_name())
|
||||
print(parent_attribute)
|
||||
print(self.parent_attribute)
|
||||
print(parent_func.get_method())
|
||||
print(self.parent_func.get_method())
|
||||
print(parent_func())
|
||||
print(self.parent_func())
|
||||
print(Nested.nested_const)
|
||||
print(self.Nested.nested_const)
|
||||
print(Parent.Nested.nested_const)
|
||||
|
||||
|
||||
func test():
|
||||
Child.new().child_test()
|
@@ -0,0 +1,16 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
parent_signal
|
||||
parent_signal
|
||||
3
|
||||
3
|
||||
parent_func
|
||||
parent_func
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
@@ -0,0 +1,5 @@
|
||||
@icon("res://path/to/optional/icon.svg")
|
||||
class_name HelloWorld
|
||||
|
||||
func test():
|
||||
pass
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
print(20 + 20)
|
||||
print("hello" + "world")
|
||||
print([1, 2] + [3, 4])
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
40
|
||||
helloworld
|
||||
[1, 2, 3, 4]
|
13
modules/gdscript/tests/scripts/parser/features/constants.gd
Normal file
13
modules/gdscript/tests/scripts/parser/features/constants.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
func test():
|
||||
const _TEST = 12 + 34 - 56 * 78
|
||||
const _STRING = "yes"
|
||||
const _VECTOR = Vector2(5, 6)
|
||||
const _ARRAY = []
|
||||
const _DICTIONARY = {"this": "dictionary"}
|
||||
const _FLOAT1 = 1e2
|
||||
const _FLOAT2 = 1E2
|
||||
|
||||
# Create user constants from built-in constants.
|
||||
const _HELLO = PI + TAU
|
||||
const _INFINITY = INF
|
||||
const _NOT_A_NUMBER = NAN
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,12 @@
|
||||
# GH-89403
|
||||
|
||||
func test():
|
||||
var x := 1
|
||||
if x == 0 \
|
||||
# Comment.
|
||||
# Comment.
|
||||
and (x < 1 or x > 2) \
|
||||
# Comment.
|
||||
and x != 3:
|
||||
pass
|
||||
print("Ok")
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
Ok
|
37
modules/gdscript/tests/scripts/parser/features/dictionary.gd
Normal file
37
modules/gdscript/tests/scripts/parser/features/dictionary.gd
Normal 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)
|
@@ -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
|
@@ -0,0 +1,9 @@
|
||||
func test():
|
||||
var lua_dict = {
|
||||
a = 1,
|
||||
"b" = 2, # Using strings are allowed too.
|
||||
"with spaces" = 3, # Especially useful when key has spaces...
|
||||
"2" = 4, # ... or invalid identifiers.
|
||||
}
|
||||
|
||||
print(lua_dict)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
{ &"a": 1, &"b": 2, &"with spaces": 3, &"2": 4 }
|
@@ -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)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
{ "hello": { &"world": { "is": "beautiful" } } }
|
@@ -0,0 +1,54 @@
|
||||
extends Node
|
||||
|
||||
func test():
|
||||
var child = Node.new()
|
||||
child.name = "Child"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
add_child(child)
|
||||
child.owner = self
|
||||
|
||||
var hey = Node.new()
|
||||
hey.name = "Hey"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
child.add_child(hey)
|
||||
hey.owner = self
|
||||
hey.unique_name_in_owner = true
|
||||
|
||||
var fake_hey = Node.new()
|
||||
fake_hey.name = "Hey"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
add_child(fake_hey)
|
||||
fake_hey.owner = self
|
||||
|
||||
var sub_child = Node.new()
|
||||
sub_child.name = "SubChild"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
hey.add_child(sub_child)
|
||||
sub_child.owner = self
|
||||
|
||||
var howdy = Node.new()
|
||||
howdy.name = "Howdy"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
sub_child.add_child(howdy)
|
||||
howdy.owner = self
|
||||
howdy.unique_name_in_owner = true
|
||||
|
||||
print(hey == $Child/Hey)
|
||||
print(howdy == $Child/Hey/SubChild/Howdy)
|
||||
|
||||
print(%Hey == hey)
|
||||
print($%Hey == hey)
|
||||
print(%"Hey" == hey)
|
||||
print($"%Hey" == hey)
|
||||
print($%"Hey" == hey)
|
||||
print(%Hey/%Howdy == howdy)
|
||||
print($%Hey/%Howdy == howdy)
|
||||
print($"%Hey/%Howdy" == howdy)
|
||||
print($"%Hey"/"%Howdy" == howdy)
|
||||
print(%"Hey"/"%Howdy" == howdy)
|
||||
print($%"Hey"/"%Howdy" == howdy)
|
||||
print($"%Hey"/%"Howdy" == howdy)
|
||||
print(%"Hey"/%"Howdy" == howdy)
|
||||
print($%"Hey"/%"Howdy" == howdy)
|
||||
print(%"Hey/%Howdy" == howdy)
|
||||
print($%"Hey/%Howdy" == howdy)
|
@@ -0,0 +1,19 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
@@ -0,0 +1,22 @@
|
||||
extends Node
|
||||
|
||||
|
||||
func test():
|
||||
# Create the required node structure.
|
||||
var hello = Node.new()
|
||||
hello.name = "Hello"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
add_child(hello)
|
||||
var world = Node.new()
|
||||
world.name = "World"
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
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"
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
14
modules/gdscript/tests/scripts/parser/features/enum.gd
Normal file
14
modules/gdscript/tests/scripts/parser/features/enum.gd
Normal 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)
|
6
modules/gdscript/tests/scripts/parser/features/enum.out
Normal file
6
modules/gdscript/tests/scripts/parser/features/enum.out
Normal file
@@ -0,0 +1,6 @@
|
||||
GDTEST_OK
|
||||
-10
|
||||
-9
|
||||
0
|
||||
10
|
||||
11
|
@@ -0,0 +1,86 @@
|
||||
@export_dir var test_dir: Array[String]
|
||||
@export_dir var test_dir_packed: PackedStringArray
|
||||
@export_file var test_file: Array[String]
|
||||
@export_file var test_file_packed: PackedStringArray
|
||||
@export_global_dir var test_global_dir: Array[String]
|
||||
@export_global_dir var test_global_dir_packed: PackedStringArray
|
||||
@export_global_file var test_global_file: Array[String]
|
||||
@export_global_file var test_global_file_packed: PackedStringArray
|
||||
@export_flags("A", "B", "C") var test_bit_flag: Array[int]
|
||||
@export_flags("A", "B", "C") var test_bit_flag_packed_byte: PackedByteArray
|
||||
@export_flags("A", "B", "C") var test_bit_flag_packed32: PackedInt32Array
|
||||
@export_flags("A", "B", "C") var test_bit_flag_packed64: PackedInt64Array
|
||||
@export_flags_2d_navigation var test_bit_flag_2d_nav: Array[int]
|
||||
@export_flags_2d_navigation var test_bit_flag_2d_nav_packed_byte: PackedByteArray
|
||||
@export_flags_2d_navigation var test_bit_flag_2d_nav_packed32: PackedInt32Array
|
||||
@export_flags_2d_navigation var test_bit_flag_2d_nav_packed64: PackedInt64Array
|
||||
@export_flags_2d_physics var test_bit_flag_2d_phys: Array[int]
|
||||
@export_flags_2d_physics var test_bit_flag_2d_phys_packed_byte: PackedByteArray
|
||||
@export_flags_2d_physics var test_bit_flag_2d_phys_packed32: PackedInt32Array
|
||||
@export_flags_2d_physics var test_bit_flag_2d_phys_packed64: PackedInt64Array
|
||||
@export_flags_2d_render var test_bit_flag_2d_render: Array[int]
|
||||
@export_flags_2d_render var test_bit_flag_2d_render_packed_byte: PackedByteArray
|
||||
@export_flags_2d_render var test_bit_flag_2d_render_packed32: PackedInt32Array
|
||||
@export_flags_2d_render var test_bit_flag_2d_render_packed64: PackedInt64Array
|
||||
@export_flags_3d_navigation var test_bit_flag_3d_nav: Array[int]
|
||||
@export_flags_3d_navigation var test_bit_flag_3d_nav_packed_byte: PackedByteArray
|
||||
@export_flags_3d_navigation var test_bit_flag_3d_nav_packed32: PackedInt32Array
|
||||
@export_flags_3d_navigation var test_bit_flag_3d_nav_packed64: PackedInt64Array
|
||||
@export_flags_3d_physics var test_bit_flag_3d_phys: Array[int]
|
||||
@export_flags_3d_physics var test_bit_flag_3d_phys_packed_byte: PackedByteArray
|
||||
@export_flags_3d_physics var test_bit_flag_3d_phys_packed32: PackedInt32Array
|
||||
@export_flags_3d_physics var test_bit_flag_3d_phys_packed64: PackedInt64Array
|
||||
@export_flags_3d_render var test_bit_flag_3d_render: Array[int]
|
||||
@export_flags_3d_render var test_bit_flag_3d_render_packed_byte: PackedByteArray
|
||||
@export_flags_3d_render var test_bit_flag_3d_render_packed32: PackedInt32Array
|
||||
@export_flags_3d_render var test_bit_flag_3d_render_packed64: PackedInt64Array
|
||||
@export_multiline var test_multiline: Array[String]
|
||||
@export_multiline var test_multiline_packed: PackedStringArray
|
||||
@export_placeholder("Placeholder") var test_placeholder: Array[String]
|
||||
@export_placeholder("Placeholder") var test_placeholder_packed: PackedStringArray
|
||||
@export_range(1, 10) var test_range_int: Array[int]
|
||||
@export_range(1, 10) var test_range_int_packed_byte: PackedByteArray
|
||||
@export_range(1, 10) var test_range_int_packed32: PackedInt32Array
|
||||
@export_range(1, 10) var test_range_int_packed64: PackedInt64Array
|
||||
@export_range(1, 10, 0.01) var test_range_int_float_step: Array[int]
|
||||
@export_range(1.0, 10.0) var test_range_float: Array[float]
|
||||
@export_range(1.0, 10.0) var test_range_float_packed32: PackedFloat32Array
|
||||
@export_range(1.0, 10.0) var test_range_float_packed64: PackedFloat64Array
|
||||
@export_exp_easing var test_exp_easing: Array[float]
|
||||
@export_exp_easing var test_exp_easing_packed32: PackedFloat32Array
|
||||
@export_exp_easing var test_exp_easing_packed64: PackedFloat64Array
|
||||
@export_node_path var test_node_path: Array[NodePath]
|
||||
@export_color_no_alpha var test_color: Array[Color]
|
||||
@export_color_no_alpha var test_color_packed: PackedColorArray
|
||||
|
||||
var temp_packed_byte_array: PackedByteArray
|
||||
var temp_packed_int32_array: PackedInt32Array
|
||||
var temp_packed_int64_array: PackedInt64Array
|
||||
var temp_packed_float32_array: PackedFloat32Array
|
||||
var temp_packed_float64_array: PackedFloat64Array
|
||||
var temp_packed_color_array: PackedColorArray
|
||||
var temp_packed_vector2_array: PackedVector2Array
|
||||
var temp_packed_vector3_array: PackedVector3Array
|
||||
var temp_packed_vector4_array: PackedVector4Array
|
||||
|
||||
@export var test_weak_packed_byte_array = temp_packed_byte_array
|
||||
@export var test_weak_packed_int32_array = temp_packed_int32_array
|
||||
@export var test_weak_packed_int64_array = temp_packed_int64_array
|
||||
@export var test_weak_packed_float32_array = temp_packed_float32_array
|
||||
@export var test_weak_packed_float64_array = temp_packed_float64_array
|
||||
@export var test_weak_packed_color_array = temp_packed_color_array
|
||||
@export var test_weak_packed_vector2_array = temp_packed_vector2_array
|
||||
@export var test_weak_packed_vector3_array = temp_packed_vector3_array
|
||||
@export var test_weak_packed_vector4_array = temp_packed_vector4_array
|
||||
|
||||
@export_range(1, 10) var test_range_weak_packed_byte_array = temp_packed_byte_array
|
||||
@export_range(1, 10) var test_range_weak_packed_int32_array = temp_packed_int32_array
|
||||
@export_range(1, 10) var test_range_weak_packed_int64_array = temp_packed_int64_array
|
||||
@export_range(1, 10) var test_range_weak_packed_float32_array = temp_packed_float32_array
|
||||
@export_range(1, 10) var test_range_weak_packed_float64_array = temp_packed_float64_array
|
||||
@export_color_no_alpha var test_noalpha_weak_packed_color_array = temp_packed_color_array
|
||||
|
||||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property)
|
139
modules/gdscript/tests/scripts/parser/features/export_arrays.out
Normal file
139
modules/gdscript/tests/scripts/parser/features/export_arrays.out
Normal file
@@ -0,0 +1,139 @@
|
||||
GDTEST_OK
|
||||
var test_dir: Array
|
||||
hint=TYPE_STRING hint_string="<String>/<DIR>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_dir_packed: PackedStringArray
|
||||
hint=TYPE_STRING hint_string="<String>/<DIR>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_file: Array
|
||||
hint=TYPE_STRING hint_string="<String>/<FILE>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_file_packed: PackedStringArray
|
||||
hint=TYPE_STRING hint_string="<String>/<FILE>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_global_dir: Array
|
||||
hint=TYPE_STRING hint_string="<String>/<GLOBAL_DIR>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_global_dir_packed: PackedStringArray
|
||||
hint=TYPE_STRING hint_string="<String>/<GLOBAL_DIR>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_global_file: Array
|
||||
hint=TYPE_STRING hint_string="<String>/<GLOBAL_FILE>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_global_file_packed: PackedStringArray
|
||||
hint=TYPE_STRING hint_string="<String>/<GLOBAL_FILE>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<FLAGS>:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<FLAGS>:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<FLAGS>:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<FLAGS>:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_nav: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_nav_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_nav_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_nav_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_phys: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_phys_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_phys_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_phys_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_render: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_render_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_render_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_2d_render_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_2D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_nav: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_nav_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_nav_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_nav_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_NAVIGATION>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_phys: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_phys_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_phys_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_phys_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_PHYSICS>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_render: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_render_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_render_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_bit_flag_3d_render_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<LAYERS_3D_RENDER>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_multiline: Array
|
||||
hint=TYPE_STRING hint_string="<String>/<MULTILINE_TEXT>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_multiline_packed: PackedStringArray
|
||||
hint=TYPE_STRING hint_string="<String>/<MULTILINE_TEXT>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_placeholder: Array
|
||||
hint=TYPE_STRING hint_string="<String>/<PLACEHOLDER_TEXT>:Placeholder" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_placeholder_packed: PackedStringArray
|
||||
hint=TYPE_STRING hint_string="<String>/<PLACEHOLDER_TEXT>:Placeholder" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_int: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_int_packed_byte: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_int_packed32: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_int_packed64: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_int_float_step: Array
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0,0.01" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_float: Array
|
||||
hint=TYPE_STRING hint_string="<float>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_float_packed32: PackedFloat32Array
|
||||
hint=TYPE_STRING hint_string="<float>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_float_packed64: PackedFloat64Array
|
||||
hint=TYPE_STRING hint_string="<float>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_exp_easing: Array
|
||||
hint=TYPE_STRING hint_string="<float>/<EXP_EASING>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_exp_easing_packed32: PackedFloat32Array
|
||||
hint=TYPE_STRING hint_string="<float>/<EXP_EASING>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_exp_easing_packed64: PackedFloat64Array
|
||||
hint=TYPE_STRING hint_string="<float>/<EXP_EASING>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_node_path: Array
|
||||
hint=TYPE_STRING hint_string="<NodePath>/<NODE_PATH_VALID_TYPES>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_color: Array
|
||||
hint=TYPE_STRING hint_string="<Color>/<COLOR_NO_ALPHA>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_color_packed: PackedColorArray
|
||||
hint=TYPE_STRING hint_string="<Color>/<COLOR_NO_ALPHA>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_byte_array: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_int32_array: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_int64_array: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_float32_array: PackedFloat32Array
|
||||
hint=TYPE_STRING hint_string="<float>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_float64_array: PackedFloat64Array
|
||||
hint=TYPE_STRING hint_string="<float>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_color_array: PackedColorArray
|
||||
hint=TYPE_STRING hint_string="<Color>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_vector2_array: PackedVector2Array
|
||||
hint=TYPE_STRING hint_string="<Vector2>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_vector3_array: PackedVector3Array
|
||||
hint=TYPE_STRING hint_string="<Vector3>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_vector4_array: PackedVector4Array
|
||||
hint=TYPE_STRING hint_string="<Vector4>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_weak_packed_byte_array: PackedByteArray
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_weak_packed_int32_array: PackedInt32Array
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_weak_packed_int64_array: PackedInt64Array
|
||||
hint=TYPE_STRING hint_string="<int>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_weak_packed_float32_array: PackedFloat32Array
|
||||
hint=TYPE_STRING hint_string="<float>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_weak_packed_float64_array: PackedFloat64Array
|
||||
hint=TYPE_STRING hint_string="<float>/<RANGE>:1.0,10.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_noalpha_weak_packed_color_array: PackedColorArray
|
||||
hint=TYPE_STRING hint_string="<Color>/<COLOR_NO_ALPHA>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
@@ -0,0 +1,35 @@
|
||||
@export_enum("Red", "Green", "Blue") var test_untyped
|
||||
@export_enum("Red:10", "Green:20", "Blue:30") var test_with_values
|
||||
|
||||
var temp_array_int: Array[int]
|
||||
var temp_array_string: Array[String]
|
||||
var temp_packed_byte_array: PackedByteArray
|
||||
var temp_packed_int32_array: PackedInt32Array
|
||||
var temp_packed_int64_array: PackedInt64Array
|
||||
var temp_packed_string_array: PackedStringArray
|
||||
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_variant
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_int = 0
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_string = ""
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_array_int = temp_array_int
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_array_string = temp_array_string
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_packed_byte_array = temp_packed_byte_array
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_packed_int32_array = temp_packed_int32_array
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_packed_int64_array = temp_packed_int64_array
|
||||
@export_enum("Red", "Green", "Blue") var test_weak_packed_string_array = temp_packed_string_array
|
||||
|
||||
@export_enum("Red", "Green", "Blue") var test_hard_variant: Variant
|
||||
@export_enum("Red", "Green", "Blue") var test_hard_int: int
|
||||
@export_enum("Red", "Green", "Blue") var test_hard_string: String
|
||||
@export_enum("Red", "Green", "Blue") var test_hard_array_int: Array[int]
|
||||
@export_enum("Red", "Green", "Blue") var test_hard_array_string: Array[String]
|
||||
|
||||
@export_enum("Red", "Green", "Blue") var test_variant_array_int: Variant = temp_array_int
|
||||
@export_enum("Red", "Green", "Blue") var test_variant_packed_int32_array: Variant = temp_packed_int32_array
|
||||
@export_enum("Red", "Green", "Blue") var test_variant_array_string: Variant = temp_array_string
|
||||
@export_enum("Red", "Green", "Blue") var test_variant_packed_string_array: Variant = temp_packed_string_array
|
||||
|
||||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property, self)
|
@@ -0,0 +1,41 @@
|
||||
GDTEST_OK
|
||||
var test_untyped: int = null
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_with_values: int = null
|
||||
hint=ENUM hint_string="Red:10,Green:20,Blue:30" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_variant: int = null
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_int: int = 0
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_string: String = ""
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_array_int: Array = Array[int]([])
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_array_string: Array = Array[String]([])
|
||||
hint=TYPE_STRING hint_string="<String>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_byte_array: PackedByteArray = PackedByteArray()
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_int32_array: PackedInt32Array = PackedInt32Array()
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_int64_array: PackedInt64Array = PackedInt64Array()
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_weak_packed_string_array: PackedStringArray = PackedStringArray()
|
||||
hint=TYPE_STRING hint_string="<String>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_hard_variant: int = null
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_hard_int: int = 0
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_hard_string: String = ""
|
||||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_hard_array_int: Array = Array[int]([])
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_hard_array_string: Array = Array[String]([])
|
||||
hint=TYPE_STRING hint_string="<String>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_variant_array_int: Array = Array[int]([])
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_variant_packed_int32_array: PackedInt32Array = PackedInt32Array()
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_variant_array_string: Array = Array[String]([])
|
||||
hint=TYPE_STRING hint_string="<String>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_variant_packed_string_array: PackedStringArray = PackedStringArray()
|
||||
hint=TYPE_STRING hint_string="<String>/<ENUM>:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
@@ -0,0 +1,58 @@
|
||||
@tool
|
||||
class_name ExportVariableTest
|
||||
extends Node
|
||||
|
||||
const PreloadedGlobalClass = preload("./export_variable_global.notest.gd")
|
||||
const PreloadedUnnamedClass = preload("./export_variable_unnamed.notest.gd")
|
||||
|
||||
# Built-in types.
|
||||
@export var test_weak_int = 1
|
||||
@export var test_hard_int: int = 2
|
||||
@export_range(0, 100) var test_range = 100
|
||||
@export_range(0, 100, 1) var test_range_step = 101
|
||||
@export_range(0, 100, 1, "or_greater") var test_range_step_or_greater = 102
|
||||
@export var test_color: Color
|
||||
@export_color_no_alpha var test_color_no_alpha: Color
|
||||
@export_node_path("Sprite2D", "Sprite3D", "Control", "Node") var test_node_path := ^"hello"
|
||||
|
||||
# Enums.
|
||||
@export var test_side: Side
|
||||
@export var test_atm: AutoTranslateMode
|
||||
|
||||
# Resources and nodes.
|
||||
@export var test_image: Image
|
||||
@export var test_timer: Timer
|
||||
|
||||
# Global custom classes.
|
||||
@export var test_global_class: ExportVariableTest
|
||||
@export var test_preloaded_global_class: PreloadedGlobalClass
|
||||
@export var test_preloaded_unnamed_class: PreloadedUnnamedClass # GH-93168
|
||||
|
||||
# Arrays.
|
||||
@export var test_array: Array
|
||||
@export var test_array_bool: Array[bool]
|
||||
@export var test_array_array: Array[Array]
|
||||
@export var test_array_side: Array[Side]
|
||||
@export var test_array_atm: Array[AutoTranslateMode]
|
||||
@export var test_array_image: Array[Image]
|
||||
@export var test_array_timer: Array[Timer]
|
||||
|
||||
# `@export_storage`.
|
||||
@export_storage var test_storage_untyped
|
||||
@export_storage var test_storage_weak_int = 3 # Property info still `Variant`, unlike `@export`.
|
||||
@export_storage var test_storage_hard_int: int = 4
|
||||
|
||||
# `@export_custom`.
|
||||
# NOTE: `PROPERTY_USAGE_NIL_IS_VARIANT` flag will be removed.
|
||||
@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_untyped
|
||||
@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_weak_int = 5
|
||||
@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_hard_int: int = 6
|
||||
|
||||
# `@export_tool_button`.
|
||||
@export_tool_button("Click me!") var test_tool_button_1: Callable
|
||||
@export_tool_button("Click me!", "ColorRect") var test_tool_button_2: Callable
|
||||
|
||||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property, self)
|
@@ -0,0 +1,61 @@
|
||||
GDTEST_OK
|
||||
var test_weak_int: int = 1
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_hard_int: int = 2
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range: int = 100
|
||||
hint=RANGE hint_string="0.0,100.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_step: int = 101
|
||||
hint=RANGE hint_string="0.0,100.0,1.0" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_range_step_or_greater: int = 102
|
||||
hint=RANGE hint_string="0.0,100.0,1.0,or_greater" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_color: Color = Color(0, 0, 0, 1)
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_color_no_alpha: Color = Color(0, 0, 0, 1)
|
||||
hint=COLOR_NO_ALPHA hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_node_path: NodePath = NodePath("hello")
|
||||
hint=NODE_PATH_VALID_TYPES hint_string="Sprite2D,Sprite3D,Control,Node" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_side: Side = 0
|
||||
hint=ENUM hint_string="Side Left:0,Side Top:1,Side Right:2,Side Bottom:3" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"Side"
|
||||
var test_atm: Node.AutoTranslateMode = 0
|
||||
hint=ENUM hint_string="Auto Translate Mode Inherit:0,Auto Translate Mode Always:1,Auto Translate Mode Disabled:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"Node.AutoTranslateMode"
|
||||
var test_image: Image = null
|
||||
hint=RESOURCE_TYPE hint_string="Image" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"Image"
|
||||
var test_timer: Timer = null
|
||||
hint=NODE_TYPE hint_string="Timer" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"Timer"
|
||||
var test_global_class: ExportVariableTest = null
|
||||
hint=NODE_TYPE hint_string="ExportVariableTest" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"ExportVariableTest"
|
||||
var test_preloaded_global_class: ExportVariableTestGlobalClass = null
|
||||
hint=NODE_TYPE hint_string="ExportVariableTestGlobalClass" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"ExportVariableTestGlobalClass"
|
||||
var test_preloaded_unnamed_class: Node2D = null
|
||||
hint=NODE_TYPE hint_string="Node2D" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"Node2D"
|
||||
var test_array: Array = []
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_array_bool: Array = Array[bool]([])
|
||||
hint=TYPE_STRING hint_string="<bool>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_array_array: Array = Array[Array]([])
|
||||
hint=TYPE_STRING hint_string="<Array>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_array_side: Array = Array[int]([])
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Side Left:0,Side Top:1,Side Right:2,Side Bottom:3" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_array_atm: Array = Array[int]([])
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Auto Translate Mode Inherit:0,Auto Translate Mode Always:1,Auto Translate Mode Disabled:2" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_array_image: Array = Array[Image]([])
|
||||
hint=TYPE_STRING hint_string="<Object>/<RESOURCE_TYPE>:Image" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_array_timer: Array = Array[Timer]([])
|
||||
hint=TYPE_STRING hint_string="<Object>/<NODE_TYPE>:Timer" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_storage_untyped: Variant = null
|
||||
hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT class_name=&""
|
||||
var test_storage_weak_int: Variant = 3
|
||||
hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT class_name=&""
|
||||
var test_storage_hard_int: int = 4
|
||||
hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE class_name=&""
|
||||
var test_export_custom_untyped: null = null
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_export_custom_weak_int: int = 5
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_export_custom_hard_int: int = 6
|
||||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
var test_tool_button_1: Callable = Callable()
|
||||
hint=TOOL_BUTTON hint_string="Click me!" usage=EDITOR|SCRIPT_VARIABLE class_name=&""
|
||||
var test_tool_button_2: Callable = Callable()
|
||||
hint=TOOL_BUTTON hint_string="Click me!,ColorRect" usage=EDITOR|SCRIPT_VARIABLE class_name=&""
|
@@ -0,0 +1,2 @@
|
||||
class_name ExportVariableTestGlobalClass
|
||||
extends Node2D
|
@@ -0,0 +1 @@
|
||||
extends Node2D
|
@@ -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))
|
@@ -0,0 +1,19 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
39
modules/gdscript/tests/scripts/parser/features/for_range.gd
Normal file
39
modules/gdscript/tests/scripts/parser/features/for_range.gd
Normal 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)
|
58
modules/gdscript/tests/scripts/parser/features/for_range.out
Normal file
58
modules/gdscript/tests/scripts/parser/features/for_range.out
Normal 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
|
||||
!
|
||||
_
|
||||
🦄
|
@@ -0,0 +1,5 @@
|
||||
func example(_number: int, _number2: int = 5, number3 := 10):
|
||||
return number3
|
||||
|
||||
func test():
|
||||
print(example(3))
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
10
|
@@ -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
|
||||
123456789101112131415161718192212223242526272829303132333435363738394041424344454647falsetrue<null>
|
@@ -0,0 +1,13 @@
|
||||
func test():
|
||||
var i_string := ''
|
||||
for i in 3:
|
||||
if i == 1: continue
|
||||
var lambda := func():
|
||||
var j_string := ''
|
||||
for j in 3:
|
||||
if j == 1: continue
|
||||
j_string += str(j)
|
||||
return j_string
|
||||
i_string += lambda.call()
|
||||
Utils.check(i_string == '0202')
|
||||
print('ok')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -0,0 +1,7 @@
|
||||
# https://github.com/godotengine/godot/issues/61231
|
||||
|
||||
func test():
|
||||
var my_lambda = func():
|
||||
print("hello")
|
||||
if 0 == 0:
|
||||
my_lambda.call()
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
hello
|
14
modules/gdscript/tests/scripts/parser/features/in.gd
Normal file
14
modules/gdscript/tests/scripts/parser/features/in.gd
Normal 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" })
|
11
modules/gdscript/tests/scripts/parser/features/in.out
Normal file
11
modules/gdscript/tests/scripts/parser/features/in.out
Normal file
@@ -0,0 +1,11 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
@@ -0,0 +1,11 @@
|
||||
func test():
|
||||
var i: Variant = 123
|
||||
var s: Variant = "str"
|
||||
prints(i is int, i is not int)
|
||||
prints(s is int, s is not int)
|
||||
|
||||
var a: Variant = false
|
||||
var b: Variant = true
|
||||
prints(a == b is int, a == b is not int)
|
||||
prints(a == (b is int), a == (b is not int))
|
||||
prints((a == b) is int, (a == b) is not int)
|
@@ -0,0 +1,6 @@
|
||||
GDTEST_OK
|
||||
true false
|
||||
false true
|
||||
true false
|
||||
true false
|
||||
false true
|
@@ -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,7 @@
|
||||
# https://github.com/godotengine/godot/issues/56751
|
||||
|
||||
func test():
|
||||
var x = "local"
|
||||
var lambda = func(param = x):
|
||||
print(param)
|
||||
lambda.call()
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
local
|
@@ -0,0 +1,62 @@
|
||||
# https://github.com/godotengine/godot/issues/73273
|
||||
|
||||
func other(callable : Callable):
|
||||
callable.call()
|
||||
|
||||
func four_parameters(_a, callable : Callable, b=func(): print(10)):
|
||||
callable.call()
|
||||
b.call()
|
||||
|
||||
func test():
|
||||
var v
|
||||
@warning_ignore("confusable_capture_reassignment")
|
||||
v=func():v=1
|
||||
if true: v=1
|
||||
print(v)
|
||||
print()
|
||||
|
||||
@warning_ignore("standalone_ternary")
|
||||
v=func(): print(2) if false else print(3)
|
||||
@warning_ignore("unsafe_cast")
|
||||
(v as Callable).call()
|
||||
print()
|
||||
|
||||
v=func():
|
||||
print(4)
|
||||
print(5)
|
||||
@warning_ignore("unsafe_cast")
|
||||
if true: (v as Callable).call()
|
||||
print()
|
||||
|
||||
@warning_ignore("unsafe_call_argument")
|
||||
other(v)
|
||||
print()
|
||||
|
||||
other(func(): print(6))
|
||||
print()
|
||||
|
||||
other(func():
|
||||
print(7)
|
||||
print(8)
|
||||
)
|
||||
print()
|
||||
|
||||
four_parameters(1,func():print(9))
|
||||
four_parameters(1,func():print(9), func(): print(11))
|
||||
four_parameters(1,func():
|
||||
print(12)
|
||||
print(13)
|
||||
, func(): print(11))
|
||||
print()
|
||||
|
||||
from_ticket()
|
||||
|
||||
func from_ticket():
|
||||
var _v
|
||||
if true: _v = (func(): test())
|
||||
if true: _v = (func(): test())
|
||||
if true: _v = (func(): test())
|
||||
|
||||
if true: _v = func(): test()
|
||||
if true: _v = func(): test()
|
||||
print(14)
|
@@ -0,0 +1,25 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
|
||||
3
|
||||
|
||||
4
|
||||
5
|
||||
|
||||
4
|
||||
5
|
||||
|
||||
6
|
||||
|
||||
7
|
||||
8
|
||||
|
||||
9
|
||||
10
|
||||
9
|
||||
11
|
||||
12
|
||||
13
|
||||
11
|
||||
|
||||
14
|
@@ -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
|
19
modules/gdscript/tests/scripts/parser/features/match.gd
Normal file
19
modules/gdscript/tests/scripts/parser/features/match.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
func test():
|
||||
var i = "Hello"
|
||||
match i:
|
||||
"Hello":
|
||||
print("hello")
|
||||
"Good bye":
|
||||
print("bye")
|
||||
_:
|
||||
print("default")
|
||||
|
||||
var j = 25
|
||||
match j:
|
||||
26:
|
||||
print("This won't match")
|
||||
_:
|
||||
print("This will match")
|
||||
|
||||
match 0:
|
||||
pass
|
3
modules/gdscript/tests/scripts/parser/features/match.out
Normal file
3
modules/gdscript/tests/scripts/parser/features/match.out
Normal file
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
hello
|
||||
This will match
|
@@ -0,0 +1,33 @@
|
||||
func foo(x):
|
||||
match x:
|
||||
["value1"]:
|
||||
print('["value1"]')
|
||||
["value1", "value2"]:
|
||||
print('["value1", "value2"]')
|
||||
|
||||
func bar(x):
|
||||
match x:
|
||||
[
|
||||
"value1"
|
||||
]:
|
||||
print('multiline ["value1"]')
|
||||
[
|
||||
"value1",
|
||||
"value2",
|
||||
]:
|
||||
print('multiline ["value1", "value2",]')
|
||||
[
|
||||
"value1",
|
||||
[
|
||||
"value2",
|
||||
..,
|
||||
],
|
||||
]:
|
||||
print('multiline ["value1", ["value2", ..,],]')
|
||||
|
||||
func test():
|
||||
foo(["value1"])
|
||||
foo(["value1", "value2"])
|
||||
bar(["value1"])
|
||||
bar(["value1", "value2"])
|
||||
bar(["value1", ["value2", "value3"]])
|
@@ -0,0 +1,6 @@
|
||||
GDTEST_OK
|
||||
["value1"]
|
||||
["value1", "value2"]
|
||||
multiline ["value1"]
|
||||
multiline ["value1", "value2",]
|
||||
multiline ["value1", ["value2", ..,],]
|
@@ -0,0 +1,13 @@
|
||||
# https://github.com/godotengine/godot/pull/61666
|
||||
|
||||
func test():
|
||||
var dict := {"key": "value"}
|
||||
match dict:
|
||||
{"key": var value}:
|
||||
print(value) # used, no warning
|
||||
match dict:
|
||||
{"key": var value}:
|
||||
pass # unused, warning
|
||||
match dict:
|
||||
{"key": var _value}:
|
||||
pass # unused, suppressed warning from underscore
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
~~ WARNING at line 9: (UNUSED_VARIABLE) The local variable "value" is declared but never used in the block. If this is intended, prefix it with an underscore: "_value".
|
||||
value
|
@@ -0,0 +1,64 @@
|
||||
func foo(x):
|
||||
match x:
|
||||
{"key1": "value1", "key2": "value2"}:
|
||||
print('{"key1": "value1", "key2": "value2"}')
|
||||
{"key1": "value1", "key2"}:
|
||||
print('{"key1": "value1", "key2"}')
|
||||
{"key1", "key2": "value2"}:
|
||||
print('{"key1", "key2": "value2"}')
|
||||
{"key1", "key2"}:
|
||||
print('{"key1", "key2"}')
|
||||
{"key1": "value1"}:
|
||||
print('{"key1": "value1"}')
|
||||
{"key1"}:
|
||||
print('{"key1"}')
|
||||
_:
|
||||
print("wildcard")
|
||||
|
||||
func bar(x):
|
||||
match x:
|
||||
{0}:
|
||||
print("0")
|
||||
{1}:
|
||||
print("1")
|
||||
{2}:
|
||||
print("2")
|
||||
_:
|
||||
print("wildcard")
|
||||
|
||||
func baz(x):
|
||||
match x:
|
||||
{
|
||||
"key1": "value1"
|
||||
}:
|
||||
print('multiline {"key1": "value1"}')
|
||||
{
|
||||
"key2": "value2",
|
||||
}:
|
||||
print('multiline {"key2": "value2",}')
|
||||
{
|
||||
"key3": {
|
||||
"key1",
|
||||
..,
|
||||
},
|
||||
}:
|
||||
print('multiline {"key3": {"key1", ..,},}')
|
||||
|
||||
func test():
|
||||
foo({"key1": "value1", "key2": "value2"})
|
||||
foo({"key1": "value1", "key2": ""})
|
||||
foo({"key1": "", "key2": "value2"})
|
||||
foo({"key1": "", "key2": ""})
|
||||
foo({"key1": "value1"})
|
||||
foo({"key1": ""})
|
||||
foo({"key1": "value1", "key2": "value2", "key3": "value3"})
|
||||
foo({"key1": "value1", "key3": ""})
|
||||
foo({"key2": "value2"})
|
||||
foo({"key3": ""})
|
||||
bar({0: "0"})
|
||||
bar({1: "1"})
|
||||
bar({2: "2"})
|
||||
bar({3: "3"})
|
||||
baz({"key1": "value1"})
|
||||
baz({"key2": "value2"})
|
||||
baz({"key3": {"key1": "value1", "key2": "value2"}})
|
@@ -0,0 +1,18 @@
|
||||
GDTEST_OK
|
||||
{"key1": "value1", "key2": "value2"}
|
||||
{"key1": "value1", "key2"}
|
||||
{"key1", "key2": "value2"}
|
||||
{"key1", "key2"}
|
||||
{"key1": "value1"}
|
||||
{"key1"}
|
||||
wildcard
|
||||
wildcard
|
||||
wildcard
|
||||
wildcard
|
||||
0
|
||||
1
|
||||
2
|
||||
wildcard
|
||||
multiline {"key1": "value1"}
|
||||
multiline {"key2": "value2",}
|
||||
multiline {"key3": {"key1", ..,},}
|
@@ -0,0 +1,25 @@
|
||||
func foo(x):
|
||||
match x:
|
||||
1, [2]:
|
||||
print('1, [2]')
|
||||
_:
|
||||
print('wildcard')
|
||||
|
||||
func bar(x):
|
||||
match x:
|
||||
[1], [2], [3]:
|
||||
print('[1], [2], [3]')
|
||||
[4]:
|
||||
print('[4]')
|
||||
_:
|
||||
print('wildcard')
|
||||
|
||||
func test():
|
||||
foo(1)
|
||||
foo([2])
|
||||
foo(2)
|
||||
bar([1])
|
||||
bar([2])
|
||||
bar([3])
|
||||
bar([4])
|
||||
bar([5])
|
@@ -0,0 +1,9 @@
|
||||
GDTEST_OK
|
||||
1, [2]
|
||||
1, [2]
|
||||
wildcard
|
||||
[1], [2], [3]
|
||||
[1], [2], [3]
|
||||
[1], [2], [3]
|
||||
[4]
|
||||
wildcard
|
@@ -0,0 +1,6 @@
|
||||
func test():
|
||||
match [1, 2, 3]:
|
||||
[var a, var b, var c]:
|
||||
print(a == 1)
|
||||
print(b == 2)
|
||||
print(c == 3)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
@@ -0,0 +1,22 @@
|
||||
func test():
|
||||
var a = 1
|
||||
match 1:
|
||||
a:
|
||||
print("reach 1")
|
||||
|
||||
var dict = { b = 2 }
|
||||
match 2:
|
||||
dict.b:
|
||||
print("reach 2")
|
||||
|
||||
var nested_dict = {
|
||||
sub = { c = 3 }
|
||||
}
|
||||
match 3:
|
||||
nested_dict.sub.c:
|
||||
print("reach 3")
|
||||
|
||||
var sub_pattern = { d = 4 }
|
||||
match [4]:
|
||||
[sub_pattern.d]:
|
||||
print("reach 4")
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
reach 1
|
||||
reach 2
|
||||
reach 3
|
||||
reach 4
|
@@ -0,0 +1,20 @@
|
||||
# Empty line:
|
||||
|
||||
|
||||
# Comment line:
|
||||
# Comment.
|
||||
|
||||
func test():
|
||||
print(1)
|
||||
|
||||
if true:
|
||||
|
||||
# Empty line:
|
||||
|
||||
|
||||
print(2)
|
||||
|
||||
# Comment line:
|
||||
# Comment.
|
||||
|
||||
print(3)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
2
|
||||
3
|
@@ -0,0 +1,7 @@
|
||||
func test():
|
||||
var __ = [
|
||||
"this",
|
||||
"is", "a","multiline",
|
||||
|
||||
"array", "with mixed indentation and trailing comma",
|
||||
]
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,24 @@
|
||||
func test():
|
||||
var x := 5
|
||||
|
||||
assert(x > 0)
|
||||
assert(x > 0,)
|
||||
assert(x > 0, 'message')
|
||||
assert(x > 0, 'message',)
|
||||
|
||||
assert(
|
||||
x > 0
|
||||
)
|
||||
assert(
|
||||
x > 0,
|
||||
)
|
||||
assert(
|
||||
x > 0,
|
||||
'message'
|
||||
)
|
||||
assert(
|
||||
x > 0,
|
||||
'message',
|
||||
)
|
||||
|
||||
print('OK')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
OK
|
@@ -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,
|
||||
}
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user