summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts/parser
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2023-02-09 18:42:22 +0300
committerDanil Alexeev <danil@alexeev.xyz>2023-04-14 21:28:46 +0300
commit5038a336bed6ccb5901c1437494e34312cfdc4ad (patch)
treeaf60d34deca77089a4929090b45ae54d1c8d29e2 /modules/gdscript/tests/scripts/parser
parentafca0b8fdd07ff2e50f421a0e5424897cff1eb77 (diff)
downloadredot-engine-5038a336bed6ccb5901c1437494e34312cfdc4ad.tar.gz
GDScript: Fix and improve annotation parsing
Diffstat (limited to 'modules/gdscript/tests/scripts/parser')
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.gd4
-rw-r--r--modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/annotations.gd48
-rw-r--r--modules/gdscript/tests/scripts/parser/features/annotations.out13
4 files changed, 67 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.gd b/modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.gd
new file mode 100644
index 0000000000..271a831732
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.gd
@@ -0,0 +1,4 @@
+@export_enum("A",, "B", "C") var a
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.out b/modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.out
new file mode 100644
index 0000000000..70eee5b39f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/errors/annotation_extra_comma.out
@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected expression as the annotation argument.
diff --git a/modules/gdscript/tests/scripts/parser/features/annotations.gd b/modules/gdscript/tests/scripts/parser/features/annotations.gd
new file mode 100644
index 0000000000..13c89a0a09
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/annotations.gd
@@ -0,0 +1,48 @@
+extends Node
+
+@export_enum("A", "B", "C") var a0
+@export_enum("A", "B", "C",) var a1
+
+@export_enum(
+ "A",
+ "B",
+ "C"
+) var a2
+
+@export_enum(
+ "A",
+ "B",
+ "C",
+) var a3
+
+@export
+var a4: int
+
+@export()
+var a5: int
+
+@export() var a6: int
+@warning_ignore("onready_with_export") @onready @export var a7: int
+@warning_ignore("onready_with_export") @onready() @export() var a8: int
+
+@warning_ignore("onready_with_export")
+@onready
+@export
+var a9: int
+
+@warning_ignore("onready_with_export")
+@onready()
+@export()
+var a10: int
+
+@warning_ignore("onready_with_export")
+@onready()
+@export()
+
+var a11: int
+
+
+func test():
+ for property in get_property_list():
+ if property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
+ print(property)
diff --git a/modules/gdscript/tests/scripts/parser/features/annotations.out b/modules/gdscript/tests/scripts/parser/features/annotations.out
new file mode 100644
index 0000000000..3af0436c53
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/annotations.out
@@ -0,0 +1,13 @@
+GDTEST_OK
+{ "name": "a0", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 }
+{ "name": "a1", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 }
+{ "name": "a2", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 }
+{ "name": "a3", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 }
+{ "name": "a4", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a5", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a6", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a7", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a8", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a9", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a10", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }
+{ "name": "a11", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 }