diff options
Diffstat (limited to 'modules/gdscript/tests/scripts/parser')
28 files changed, 159 insertions, 26 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/errors/duplicate_icon.gd b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.gd new file mode 100644 index 0000000000..7500e406f6 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.gd @@ -0,0 +1,5 @@ +@icon("res://1.png") +@icon("res://1.png") + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.out b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.out new file mode 100644 index 0000000000..d6cbc95d10 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_icon.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +"@icon" annotation can only be used once. diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.gd b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.gd new file mode 100644 index 0000000000..3a2f7118f9 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.gd @@ -0,0 +1,5 @@ +@tool +@tool + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.out b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.out new file mode 100644 index 0000000000..26fe23fb78 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/duplicate_tool.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +"@tool" annotation can only be used once. diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd new file mode 100644 index 0000000000..cbfa1f314f --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.gd @@ -0,0 +1,5 @@ +func _static_init(): + print("static init") + +func test(): + print("done") diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out new file mode 100644 index 0000000000..b2b8711e96 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_not_static.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +Static constructor must be declared static. diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd new file mode 100644 index 0000000000..711243f822 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.gd @@ -0,0 +1,6 @@ +static func _static_init(): + print("static init") + return true + +func test(): + print("done") diff --git a/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out new file mode 100644 index 0000000000..a034850e86 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/static_constructor_returning_something.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +Constructor cannot return a value. 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 } diff --git a/modules/gdscript/tests/scripts/parser/features/constants.out b/modules/gdscript/tests/scripts/parser/features/constants.out index 6093e4a6ca..7ec33470d3 100644 --- a/modules/gdscript/tests/scripts/parser/features/constants.out +++ b/modules/gdscript/tests/scripts/parser/features/constants.out @@ -2,32 +2,32 @@ 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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' +>> 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". diff --git a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out index 057c1b11e5..44d29cb82d 100644 --- a/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out +++ b/modules/gdscript/tests/scripts/parser/features/match_bind_unused.out @@ -2,5 +2,5 @@ GDTEST_OK >> WARNING >> 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' +>> The local variable "value" is declared but never used in the block. If this is intended, prefix it with an underscore: "_value". value diff --git a/modules/gdscript/tests/scripts/parser/features/reserved_keywords_as_attribute.gd b/modules/gdscript/tests/scripts/parser/features/reserved_keywords_as_attribute.gd new file mode 100644 index 0000000000..87f9479812 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/reserved_keywords_as_attribute.gd @@ -0,0 +1,36 @@ +var dict = {} + +func test(): + dict.if = 1 + dict.elif = 1 + dict.else = 1 + dict.for = 1 + dict.while = 1 + dict.match = 1 + dict.break = 1 + dict.continue = 1 + dict.pass = 1 + dict.return = 1 + dict.class = 1 + dict.class_name = 1 + dict.extends = 1 + dict.is = 1 + dict.in = 1 + dict.as = 1 + dict.self = 1 + dict.signal = 1 + dict.func = 1 + dict.static = 1 + dict.const = 1 + dict.enum = 1 + dict.var = 1 + dict.breakpoint = 1 + dict.preload = 1 + dict.await = 1 + dict.yield = 1 + dict.assert = 1 + dict.void = 1 + dict.PI = 1 + dict.TAU = 1 + dict.INF = 1 + dict.NAN = 1 diff --git a/modules/gdscript/tests/scripts/parser/features/reserved_keywords_as_attribute.out b/modules/gdscript/tests/scripts/parser/features/reserved_keywords_as_attribute.out new file mode 100644 index 0000000000..d73c5eb7cd --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/reserved_keywords_as_attribute.out @@ -0,0 +1 @@ +GDTEST_OK diff --git a/modules/gdscript/tests/scripts/parser/features/static_typing.out b/modules/gdscript/tests/scripts/parser/features/static_typing.out index 207d90fef1..40a8f97416 100644 --- a/modules/gdscript/tests/scripts/parser/features/static_typing.out +++ b/modules/gdscript/tests/scripts/parser/features/static_typing.out @@ -2,20 +2,20 @@ GDTEST_OK >> WARNING >> Line: 11 >> 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' +>> The local constant "_INTEGER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER". >> WARNING >> Line: 12 >> 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' +>> 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: 13 >> 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' +>> 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: 14 >> 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' +>> 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: 15 >> 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' +>> 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". diff --git a/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out b/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out index e89bb9226f..f2db4e9307 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out +++ b/modules/gdscript/tests/scripts/parser/warnings/return_value_discarded.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 6 >> RETURN_VALUE_DISCARDED ->> The function 'i_return_int()' returns a value that will be discarded if not used. +>> The function "i_return_int()" returns a value that will be discarded if not used. diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out index 9c9417e11d..75fa01f928 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_constant.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 8 >> 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' +>> The local constant "TEST" is declared but never used in the block. If this is intended, prefix it with an underscore: "_TEST". >> WARNING >> Line: 8 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out index c613140eb8..75a02c5d3c 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_global_identifier.out @@ -2,8 +2,8 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_VARIABLE ->> The local variable 'abs' is declared but never used in the block. If this is intended, prefix it with an underscore: '_abs' +>> The local variable "abs" is declared but never used in the block. If this is intended, prefix it with an underscore: "_abs". >> WARNING >> Line: 2 >> SHADOWED_GLOBAL_IDENTIFIER ->> The variable 'abs' has the same name as a built-in function. +>> The variable "abs" has the same name as a built-in function. diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out index 82e467b368..aab27e78e2 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_class.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 8 >> UNUSED_VARIABLE ->> The local variable 'foo' is declared but never used in the block. If this is intended, prefix it with an underscore: '_foo' +>> The local variable "foo" is declared but never used in the block. If this is intended, prefix it with an underscore: "_foo". >> WARNING >> Line: 8 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out index 26ce0465b1..e3cd358126 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out +++ b/modules/gdscript/tests/scripts/parser/warnings/shadowed_variable_function.out @@ -2,7 +2,7 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_VARIABLE ->> The local variable 'test' is declared but never used in the block. If this is intended, prefix it with an underscore: '_test' +>> The local variable "test" is declared but never used in the block. If this is intended, prefix it with an underscore: "_test". >> WARNING >> Line: 2 >> SHADOWED_VARIABLE diff --git a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out index 3933a35178..77994ce9ba 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out +++ b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out @@ -2,6 +2,6 @@ GDTEST_OK >> WARNING >> Line: 11 >> STATIC_CALLED_ON_INSTANCE ->> The function 'num_uint64()' is a static function but was called from an instance. Instead, it should be directly called from the type: 'String.num_uint64()'. +>> The function "num_uint64()" is a static function but was called from an instance. Instead, it should be directly called from the type: "String.num_uint64()". 8589934592 8589934592 diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out index cf14502e9a..10f89be132 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNASSIGNED_VARIABLE ->> The variable '__' was used but never assigned a value. +>> The variable "__" was used but never assigned a value. diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out index ba55a4e0f8..4fc91487f2 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable_op_assign.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 4 >> UNASSIGNED_VARIABLE_OP_ASSIGN ->> Using assignment with operation but the variable '__' was not previously assigned a value. +>> Using assignment with operation but the variable "__" was not previously assigned a value. diff --git a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out index 9316abd5eb..f67dbdcd03 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unreachable_code_after_return.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 7 >> UNREACHABLE_CODE ->> Unreachable code (statement after return) in function 'test()'. +>> Unreachable code (statement after return) in function "test()". diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out b/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out index 92f3308f85..3a03406f92 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unused_argument.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_PARAMETER ->> The parameter 'p_arg2' is never used in the function 'function_with_unused_argument'. If this is intended, prefix it with an underscore: '_p_arg2' +>> The parameter "p_arg2" is never used in the function "function_with_unused_argument()". If this is intended, prefix it with an underscore: "_p_arg2". diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out index 270e0e69c0..b9b3968473 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out +++ b/modules/gdscript/tests/scripts/parser/warnings/unused_variable.out @@ -2,4 +2,4 @@ GDTEST_OK >> WARNING >> Line: 2 >> UNUSED_VARIABLE ->> The local variable 'unused' is declared but never used in the block. If this is intended, prefix it with an underscore: '_unused' +>> The local variable "unused" is declared but never used in the block. If this is intended, prefix it with an underscore: "_unused". |